Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Get the player
- local player = game.Players.LocalPlayer
- -- Create GUI
- local gui = Instance.new("ScreenGui", player.PlayerGui)
- gui.ResetOnSpawn = false
- -- Create Frame
- local frame = Instance.new("Frame", gui)
- frame.Size = UDim2.new(0, 150, 0, 250) -- Increased size for new button
- frame.Position = UDim2.new(0.5, -75, 0.5, -75)
- frame.BackgroundColor3 = Color3.fromRGB(125, 255, 255)
- frame.Active, frame.Draggable = true, true
- -- Create Buttons
- local function createButton(text, pos, color, parent, size)
- local btn = Instance.new("TextButton", parent)
- btn.Size = size or UDim2.new(0, 120, 0, 30)
- btn.Position = pos
- btn.BackgroundColor3 = color
- btn.Text = text
- return btn
- end
- -- Repositioned Buttons on the Frame
- local spawnoneButton = createButton("เปิดออโต้วาปเก็บของ", UDim2.new(0.1, 0, 0.1, 0), Color3.fromRGB(255, 255, 255), frame)
- local collectItemsButton = createButton("เปิดเก็บเข้าเป๋า", UDim2.new(0.1, 0, 0.3, 0), Color3.fromRGB(0, 255, 0), frame)
- local autoSomTamButton = createButton("เปิดออโต้ส้มตำ", UDim2.new(0.1, 0, 0.5, 0), Color3.fromRGB(255, 165, 0), frame)
- local minimizeButton = createButton("ย่อเมนู", UDim2.new(0.1, 0, 0.7, 0), Color3.fromRGB(255, 0, 0), frame)
- -- Smaller openButton to toggle frame visibility
- local openButton = createButton("เปิด", UDim2.new(0.02, 0, 0.02, 0), Color3.fromRGB(125, 255, 125), gui, UDim2.new(0, 60, 0, 20))
- openButton.Visible = false
- -- Variables for Collect and Auto Som Tam
- local isCollectingItems = false
- local collectItemsLoop
- local isAutoSomTamActive = false
- local autoSomTamLoop
- -- Function to equip the item
- local replicatedStorage = game:GetService("ReplicatedStorage")
- local toolsFolder = replicatedStorage:WaitForChild("Tools"):WaitForChild("Items")
- local function equipMatchingItem()
- local backpack = player:WaitForChild("Backpack")
- -- Loop through all items in the Tools.Items folder
- for _, item in ipairs(toolsFolder:GetChildren()) do
- local itemName = item.Name
- -- Check if the item exists in the backpack
- local backpackItem = backpack:FindFirstChild(itemName)
- if backpackItem then
- -- Equip the item
- player.Character.Humanoid:EquipTool(backpackItem)
- -- Fire the network event with the item name
- replicatedStorage.Modules.NetworkFramework.NetworkEvent:FireServer("fire", nil, "AddInventory", itemName)
- return -- Exit after equipping the first matching item
- end
- end
- warn("No matching item found in Backpack.")
- end
- -- Collect Items Button functionality
- collectItemsButton.MouseButton1Click:Connect(function()
- isCollectingItems = not isCollectingItems
- collectItemsButton.Text = isCollectingItems and "ปิดเก็บเข้าเป๋า" or "เปิดเก็บเข้าเป๋า"
- if isCollectingItems then
- collectItemsLoop = game:GetService("RunService").Stepped:Connect(function()
- equipMatchingItem()
- wait(0.1) -- Wait time before the next loop iteration
- end)
- else
- if collectItemsLoop then
- collectItemsLoop:Disconnect()
- collectItemsLoop = nil
- end
- end
- end)
- -- Auto Som Tam Button functionality
- autoSomTamButton.MouseButton1Click:Connect(function()
- isAutoSomTamActive = not isAutoSomTamActive
- autoSomTamButton.Text = isAutoSomTamActive and "ปิดออโต้ส้มตำ" or "เปิดออโต้ส้มตำ"
- if isAutoSomTamActive then
- autoSomTamLoop = game:GetService("RunService").Stepped:Connect(function()
- local character = player.Character or player.CharacterAdded:Wait()
- local backpack = player.Backpack
- local function teleportTo(part)
- character:SetPrimaryPartCFrame(part.CFrame)
- end
- local function clickPart(part)
- local clickDetector = part:FindFirstChildOfClass("ClickDetector")
- if clickDetector then
- fireclickdetector(clickDetector)
- else
- warn("ClickDetector not found in the part.")
- end
- end
- local function holdProximityPrompt(proximityPrompt)
- if proximityPrompt then
- proximityPrompt:InputHoldBegin()
- task.wait(1)
- proximityPrompt:InputHoldEnd()
- else
- warn("ProximityPrompt not found.")
- end
- end
- local function checkAndAct()
- local workingVisible = character.Head.BillboardGui.Frame.Working.Visible
- local hasSomtamTool = backpack:FindFirstChild("Somtam ") or character:FindFirstChild("Somtam ")
- if workingVisible then
- if not hasSomtamTool then
- teleportTo(workspace.Model.SomtumBase.Circle)
- clickPart(workspace.Model.SomtumBase.Circle)
- else
- local tool = backpack:FindFirstChild("Somtam ") or character:FindFirstChild("Somtam ")
- if tool then
- tool.Parent = character
- local npc = workspace.NPC_WORK:GetChildren()[math.random(1, #workspace.NPC_WORK:GetChildren())]
- teleportTo(npc.HumanoidRootPart)
- tool:Activate()
- end
- end
- else
- teleportTo(workspace.NPC.Somtum.HumanoidRootPart)
- holdProximityPrompt(workspace.NPC.Somtum.HumanoidRootPart.ProximityPrompt)
- end
- end
- checkAndAct()
- wait(0.1)
- end)
- else
- if autoSomTamLoop then
- autoSomTamLoop:Disconnect()
- autoSomTamLoop = nil
- end
- end
- end)
- -- Toggle Spawn
- local isSpawnOne = false
- spawnoneButton.MouseButton1Click:Connect(function()
- isSpawnOne = not isSpawnOne
- spawnoneButton.Text = isSpawnOne and "ปิดออโต้วาปเก็บของ" or "เปิดออโต้วาปเก็บของ"
- while isSpawnOne do
- local part = game.Workspace.FX:FindFirstChild("XDRandom")
- if part then
- player.Character:SetPrimaryPartCFrame(part.CFrame)
- fireclickdetector(part:FindFirstChildOfClass("ClickDetector"))
- end
- wait(0.1)
- end
- end)
- -- Minimize and Maximize Functions
- minimizeButton.MouseButton1Click:Connect(function()
- frame.Visible = false
- openButton.Visible = true
- end)
- openButton.MouseButton1Click:Connect(function()
- frame.Visible = true
- openButton.Visible = false
- end)
- -- Drag Function (for both mobile and PC)
- local function enableDragging(guiElement)
- local dragging = false
- local dragStart, startPos
- local function update(input)
- local delta = input.Position - dragStart
- guiElement.Position = UDim2.new(
- startPos.X.Scale, startPos.X.Offset + delta.X,
- startPos.Y.Scale, startPos.Y.Offset + delta.Y
- )
- end
- guiElement.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
- dragging = true
- dragStart = input.Position
- startPos = guiElement.Position
- input.Changed:Connect(function()
- if input.UserInputState == Enum.UserInputState.End then
- dragging = false
- end
- end)
- end
- end)
- guiElement.InputChanged:Connect(function(input)
- if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
- update(input)
- end
- end)
- end
- -- Enable dragging for both frame and openButton
- enableDragging(frame)
- enableDragging(openButton)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement