Roblox-Bot-Lua/Main/GaG/SimpleUI.lua
2025-07-21 10:41:54 +07:00

604 lines
23 KiB
Lua

-- Simple GaG UI
-- สคริปต์ง่ายๆ สำหรับ GaG Auto Farm
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
-- Settings
local Settings = {
AutoFarm = false,
AutoSell = false,
SelectedPlant = "Carrot",
FarmDelay = 0.5
}
-- สร้าง UI แบบง่าย
local function CreateSimpleUI()
-- ScreenGui หลัก
local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Name = "SimpleGaGUI"
ScreenGui.Parent = PlayerGui
ScreenGui.ResetOnSpawn = false
-- Main Frame
local MainFrame = Instance.new("Frame")
MainFrame.Name = "MainFrame"
MainFrame.Parent = ScreenGui
MainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
MainFrame.BorderColor3 = Color3.fromRGB(0, 162, 255)
MainFrame.BorderSizePixel = 2
MainFrame.Position = UDim2.new(0.1, 0, 0.1, 0)
MainFrame.Size = UDim2.new(0, 350, 0, 450)
MainFrame.Active = true
MainFrame.Draggable = true
-- Title Bar
local TitleBar = Instance.new("Frame")
TitleBar.Name = "TitleBar"
TitleBar.Parent = MainFrame
TitleBar.BackgroundColor3 = Color3.fromRGB(0, 162, 255)
TitleBar.BorderSizePixel = 0
TitleBar.Size = UDim2.new(1, 0, 0, 30)
local Title = Instance.new("TextLabel")
Title.Name = "Title"
Title.Parent = TitleBar
Title.BackgroundTransparency = 1
Title.Size = UDim2.new(1, -30, 1, 0)
Title.Font = Enum.Font.SourceSansBold
Title.Text = "Simple GaG Auto Farm"
Title.TextColor3 = Color3.fromRGB(255, 255, 255)
Title.TextSize = 16
Title.TextXAlignment = Enum.TextXAlignment.Left
Title.TextYAlignment = Enum.TextYAlignment.Center
-- Close Button
local CloseButton = Instance.new("TextButton")
CloseButton.Name = "CloseButton"
CloseButton.Parent = TitleBar
CloseButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
CloseButton.BorderSizePixel = 0
CloseButton.Position = UDim2.new(1, -30, 0, 0)
CloseButton.Size = UDim2.new(0, 30, 0, 30)
CloseButton.Font = Enum.Font.SourceSansBold
CloseButton.Text = "X"
CloseButton.TextColor3 = Color3.fromRGB(255, 255, 255)
CloseButton.TextSize = 14
-- Content Frame
local ContentFrame = Instance.new("Frame")
ContentFrame.Name = "ContentFrame"
ContentFrame.Parent = MainFrame
ContentFrame.BackgroundTransparency = 1
ContentFrame.Position = UDim2.new(0, 10, 0, 40)
ContentFrame.Size = UDim2.new(1, -20, 1, -50)
return ScreenGui, MainFrame, ContentFrame, CloseButton
end
-- สร้าง Toggle Button
local function CreateToggle(parent, text, position, callback)
local Frame = Instance.new("Frame")
Frame.Parent = parent
Frame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
Frame.BorderColor3 = Color3.fromRGB(70, 70, 70)
Frame.BorderSizePixel = 1
Frame.Position = position
Frame.Size = UDim2.new(1, 0, 0, 40)
local Label = Instance.new("TextLabel")
Label.Parent = Frame
Label.BackgroundTransparency = 1
Label.Position = UDim2.new(0, 10, 0, 0)
Label.Size = UDim2.new(1, -60, 1, 0)
Label.Font = Enum.Font.SourceSans
Label.Text = text
Label.TextColor3 = Color3.fromRGB(255, 255, 255)
Label.TextSize = 14
Label.TextXAlignment = Enum.TextXAlignment.Left
local ToggleButton = Instance.new("TextButton")
ToggleButton.Parent = Frame
ToggleButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
ToggleButton.BorderSizePixel = 0
ToggleButton.Position = UDim2.new(1, -40, 0, 10)
ToggleButton.Size = UDim2.new(0, 30, 0, 20)
ToggleButton.Font = Enum.Font.SourceSans
ToggleButton.Text = "OFF"
ToggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
ToggleButton.TextSize = 10
local isToggled = false
ToggleButton.MouseButton1Click:Connect(function()
isToggled = not isToggled
if isToggled then
ToggleButton.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
ToggleButton.Text = "ON"
else
ToggleButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
ToggleButton.Text = "OFF"
end
if callback then
callback(isToggled)
end
end)
return Frame, ToggleButton
end
-- สร้าง Dropdown
local function CreateDropdown(parent, text, position, options, callback)
local Frame = Instance.new("Frame")
Frame.Parent = parent
Frame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
Frame.BorderColor3 = Color3.fromRGB(70, 70, 70)
Frame.BorderSizePixel = 1
Frame.Position = position
Frame.Size = UDim2.new(1, 0, 0, 40)
local Label = Instance.new("TextLabel")
Label.Parent = Frame
Label.BackgroundTransparency = 1
Label.Position = UDim2.new(0, 10, 0, 0)
Label.Size = UDim2.new(0.5, 0, 1, 0)
Label.Font = Enum.Font.SourceSans
Label.Text = text
Label.TextColor3 = Color3.fromRGB(255, 255, 255)
Label.TextSize = 14
Label.TextXAlignment = Enum.TextXAlignment.Left
local DropdownButton = Instance.new("TextButton")
DropdownButton.Parent = Frame
DropdownButton.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
DropdownButton.BorderSizePixel = 0
DropdownButton.Position = UDim2.new(0.5, 5, 0, 5)
DropdownButton.Size = UDim2.new(0.5, -15, 1, -10)
DropdownButton.Font = Enum.Font.SourceSans
DropdownButton.Text = options[1] or "Select"
DropdownButton.TextColor3 = Color3.fromRGB(255, 255, 255)
DropdownButton.TextSize = 12
local DropdownFrame = Instance.new("Frame")
DropdownFrame.Parent = Frame
DropdownFrame.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
DropdownFrame.BorderColor3 = Color3.fromRGB(70, 70, 70)
DropdownFrame.BorderSizePixel = 1
DropdownFrame.Position = UDim2.new(0.5, 5, 1, 0)
DropdownFrame.Size = UDim2.new(0.5, -15, 0, #options * 25)
DropdownFrame.Visible = false
DropdownFrame.ZIndex = 10
local isOpen = false
DropdownButton.MouseButton1Click:Connect(function()
isOpen = not isOpen
DropdownFrame.Visible = isOpen
end)
for i, option in ipairs(options) do
local OptionButton = Instance.new("TextButton")
OptionButton.Parent = DropdownFrame
OptionButton.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
OptionButton.BorderSizePixel = 0
OptionButton.Position = UDim2.new(0, 0, 0, (i-1) * 25)
OptionButton.Size = UDim2.new(1, 0, 0, 25)
OptionButton.Font = Enum.Font.SourceSans
OptionButton.Text = option
OptionButton.TextColor3 = Color3.fromRGB(255, 255, 255)
OptionButton.TextSize = 12
OptionButton.ZIndex = 11
OptionButton.MouseEnter:Connect(function()
OptionButton.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
end)
OptionButton.MouseLeave:Connect(function()
OptionButton.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
end)
OptionButton.MouseButton1Click:Connect(function()
DropdownButton.Text = option
DropdownFrame.Visible = false
isOpen = false
if callback then
callback(option)
end
end)
end
return Frame, DropdownButton
end
-- ฟังก์ชัน Farm หลัก (ปรับให้ทำงานจริง)
local FarmConnection
local function StartAutoFarm()
if FarmConnection then
FarmConnection:Disconnect()
end
FarmConnection = RunService.Heartbeat:Connect(function()
if not Settings.AutoFarm then
return
end
local success, error = pcall(function()
-- หาผู้เล่น plots
local plots = {}
-- วิธีที่ 1: หาจาก Workspace
for _, obj in pairs(Workspace:GetChildren()) do
if obj.Name == "Plots" then
for _, plot in pairs(obj:GetChildren()) do
if plot:FindFirstChild("Owner") and plot.Owner.Value == Player then
table.insert(plots, plot)
end
end
elseif obj.Name:find("Plot") and obj:FindFirstChild("Owner") and obj.Owner.Value == Player then
table.insert(plots, obj)
end
end
-- วิธีที่ 2: หาจาก workspace โดยตรง
if #plots == 0 then
for _, obj in pairs(Workspace:GetDescendants()) do
if obj.Name:find("Plot") and obj:FindFirstChild("Owner") then
if obj.Owner.Value == Player then
table.insert(plots, obj)
end
end
end
end
print("พบ Plots จำนวน: " .. #plots)
-- ทำงานกับแต่ละ plot
for _, plot in pairs(plots) do
local plant = plot:FindFirstChild("Plant")
local plotModel = plot:FindFirstChild("PlotModel") or plot
-- ตรวจสอบพืชที่โตแล้ว
if plant then
-- หาวิธีตรวจสอบว่าพืชโตแล้ว
local isGrown = false
if plant:FindFirstChild("IsGrown") then
isGrown = plant.IsGrown.Value
elseif plant:FindFirstChild("Grown") then
isGrown = plant.Grown.Value
elseif plant:FindFirstChild("Ready") then
isGrown = plant.Ready.Value
elseif plant:GetAttribute("IsGrown") then
isGrown = plant:GetAttribute("IsGrown")
elseif plant:GetAttribute("Grown") then
isGrown = plant:GetAttribute("Grown")
end
if isGrown then
print("เก็บพืชใน plot: " .. plot.Name)
-- ลองหลายวิธีเก็บพืช
local harvestSuccess = false
-- วิธีที่ 1: ใช้ RemoteEvent
local remotes = ReplicatedStorage:GetDescendants()
for _, remote in pairs(remotes) do
if remote:IsA("RemoteEvent") then
local name = remote.Name:lower()
if name:find("harvest") or name:find("collect") or name:find("pick") then
pcall(function()
remote:FireServer(plot)
harvestSuccess = true
end)
if harvestSuccess then break end
pcall(function()
remote:FireServer(plant)
harvestSuccess = true
end)
if harvestSuccess then break end
end
end
end
-- วิธีที่ 2: คลิกที่พืช
if not harvestSuccess and plant:FindFirstChild("ClickDetector") then
fireclickdetector(plant.ClickDetector)
harvestSuccess = true
end
-- วิธีที่ 3: ใช้ ProximityPrompt
if not harvestSuccess then
local prompt = plant:FindFirstChildOfClass("ProximityPrompt")
if prompt then
fireproximityprompt(prompt)
harvestSuccess = true
end
end
if harvestSuccess then
wait(0.2)
end
end
else
-- ปลูกพืชใหม่
print("ปลูกพืชใน plot: " .. plot.Name)
local plantSuccess = false
-- หาวิธีปลูกพืช
local remotes = ReplicatedStorage:GetDescendants()
for _, remote in pairs(remotes) do
if remote:IsA("RemoteEvent") then
local name = remote.Name:lower()
if name:find("plant") or name:find("seed") or name:find("buy") then
pcall(function()
remote:FireServer(Settings.SelectedPlant, plot)
plantSuccess = true
end)
if plantSuccess then break end
pcall(function()
remote:FireServer(plot, Settings.SelectedPlant)
plantSuccess = true
end)
if plantSuccess then break end
pcall(function()
remote:FireServer("PlantSeed", Settings.SelectedPlant, plot)
plantSuccess = true
end)
if plantSuccess then break end
end
end
end
if plantSuccess then
wait(0.2)
end
end
end
end)
if not success then
warn("Auto Farm Error: " .. tostring(error))
end
wait(Settings.FarmDelay)
end)
end
local function StopAutoFarm()
if FarmConnection then
FarmConnection:Disconnect()
FarmConnection = nil
end
end
-- ฟังก์ชัน Auto Sell (ปรับให้ทำงานจริง)
local SellConnection
local function StartAutoSell()
if SellConnection then
SellConnection:Disconnect()
end
SellConnection = RunService.Heartbeat:Connect(function()
if not Settings.AutoSell then
return
end
local success, error = pcall(function()
-- หาวิธีขาย
local sellSuccess = false
-- วิธีที่ 1: ใช้ RemoteEvent
local remotes = ReplicatedStorage:GetDescendants()
for _, remote in pairs(remotes) do
if remote:IsA("RemoteEvent") then
local name = remote.Name:lower()
if name:find("sell") or name:find("shop") or name:find("trade") then
pcall(function()
remote:FireServer()
sellSuccess = true
print("ขายสำเร็จผ่าน: " .. remote.Name)
end)
if sellSuccess then break end
-- ลองส่งข้อมูลเพิ่ม
pcall(function()
remote:FireServer("SellAll")
sellSuccess = true
print("ขายสำเร็จผ่าน: " .. remote.Name .. " (SellAll)")
end)
if sellSuccess then break end
end
end
end
-- วิธีที่ 2: หาพื้นที่ขายและคลิก
if not sellSuccess then
local sellAreas = {}
-- หาใน Workspace
for _, obj in pairs(Workspace:GetDescendants()) do
local name = obj.Name:lower()
if name:find("sell") or name:find("shop") or name:find("store") then
table.insert(sellAreas, obj)
end
end
for _, sellArea in pairs(sellAreas) do
-- ลองคลิก ClickDetector
local clickDetector = sellArea:FindFirstChildOfClass("ClickDetector")
if clickDetector then
fireclickdetector(clickDetector)
sellSuccess = true
print("ขายสำเร็จผ่าน ClickDetector: " .. sellArea.Name)
break
end
-- ลอง ProximityPrompt
local prompt = sellArea:FindFirstChildOfClass("ProximityPrompt")
if prompt then
fireproximityprompt(prompt)
sellSuccess = true
print("ขายสำเร็จผ่าน ProximityPrompt: " .. sellArea.Name)
break
end
end
end
-- วิธีที่ 3: teleport ไปขาย
if not sellSuccess then
for _, obj in pairs(Workspace:GetDescendants()) do
if obj.Name:lower():find("sell") and obj:IsA("Part") then
-- teleport ไปที่พื้นที่ขาย
if Player.Character and Player.Character:FindFirstChild("HumanoidRootPart") then
Player.Character.HumanoidRootPart.CFrame = obj.CFrame + Vector3.new(0, 5, 0)
wait(0.5)
-- ลองคลิกหลังจาก teleport
local clickDetector = obj:FindFirstChildOfClass("ClickDetector")
if clickDetector then
fireclickdetector(clickDetector)
sellSuccess = true
print("ขายสำเร็จหลัง teleport: " .. obj.Name)
end
break
end
end
end
end
if not sellSuccess then
print("ไม่สามารถขายได้ - กำลังลองวิธีอื่น...")
end
end)
if not success then
warn("Auto Sell Error: " .. tostring(error))
end
wait(3) -- รอ 3 วินาทีก่อนขายครั้งต่อไป
end)
end
local function StopAutoSell()
if SellConnection then
SellConnection:Disconnect()
SellConnection = nil
end
end
-- สร้าง UI หลัก
local function InitializeUI()
local ScreenGui, MainFrame, ContentFrame, CloseButton = CreateSimpleUI()
-- ปุ่มปิด
CloseButton.MouseButton1Click:Connect(function()
ScreenGui:Destroy()
StopAutoFarm()
StopAutoSell()
end)
-- สร้าง Toggle สำหรับ Auto Farm
local autoFarmFrame, autoFarmToggle = CreateToggle(
ContentFrame,
"Auto Farm",
UDim2.new(0, 0, 0, 10),
function(state)
Settings.AutoFarm = state
if state then
StartAutoFarm()
print("Auto Farm: ON")
else
StopAutoFarm()
print("Auto Farm: OFF")
end
end
)
-- สร้าง Dropdown สำหรับเลือกพืช
local plantOptions = {
"Carrot", "Strawberry", "Blueberry", "Tomato", "Corn",
"Watermelon", "Pumpkin", "Apple", "Coconut", "Mango"
}
local plantFrame, plantDropdown = CreateDropdown(
ContentFrame,
"Select Plant:",
UDim2.new(0, 0, 0, 60),
plantOptions,
function(selectedPlant)
Settings.SelectedPlant = selectedPlant
print("Selected Plant:", selectedPlant)
end
)
-- สร้าง Toggle สำหรับ Auto Sell
local autoSellFrame, autoSellToggle = CreateToggle(
ContentFrame,
"Auto Sell",
UDim2.new(0, 0, 0, 110),
function(state)
Settings.AutoSell = state
if state then
StartAutoSell()
print("Auto Sell: ON")
else
StopAutoSell()
print("Auto Sell: OFF")
end
end
)
-- สร้างป้ายแสดงสถานะ
local StatusFrame = Instance.new("Frame")
StatusFrame.Parent = ContentFrame
StatusFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
StatusFrame.BorderColor3 = Color3.fromRGB(70, 70, 70)
StatusFrame.BorderSizePixel = 1
StatusFrame.Position = UDim2.new(0, 0, 0, 160)
StatusFrame.Size = UDim2.new(1, 0, 0, 100)
local StatusLabel = Instance.new("TextLabel")
StatusLabel.Parent = StatusFrame
StatusLabel.BackgroundTransparency = 1
StatusLabel.Size = UDim2.new(1, 0, 1, 0)
StatusLabel.Font = Enum.Font.SourceSans
StatusLabel.Text = "Status: Ready\nSelected Plant: Carrot\nFarm: OFF | Sell: OFF"
StatusLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
StatusLabel.TextSize = 12
StatusLabel.TextYAlignment = Enum.TextYAlignment.Top
-- อัปเดตสถานะ
spawn(function()
while ScreenGui.Parent do
StatusLabel.Text = string.format(
"Status: Running\nSelected Plant: %s\nFarm: %s | Sell: %s",
Settings.SelectedPlant,
Settings.AutoFarm and "ON" or "OFF",
Settings.AutoSell and "ON" or "OFF"
)
wait(1)
end
end)
print("Simple GaG UI Loaded!")
end
-- เริ่มต้น UI
InitializeUI()
return {
Settings = Settings,
StartAutoFarm = StartAutoFarm,
StopAutoFarm = StopAutoFarm,
StartAutoSell = StartAutoSell,
StopAutoSell = StopAutoSell
}