Advertisement
Me_Hker

Error Zone

Oct 19th, 2024 (edited)
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.15 KB | Gaming | 0 0
  1. -- Get the player
  2. local player = game.Players.LocalPlayer
  3.  
  4. -- Create GUI
  5. local gui = Instance.new("ScreenGui", player.PlayerGui)
  6. gui.ResetOnSpawn = false
  7.  
  8. -- Create Frame
  9. local frame = Instance.new("Frame", gui)
  10. frame.Size = UDim2.new(0, 150, 0, 250)  -- Increased size for new button
  11. frame.Position = UDim2.new(0.5, -75, 0.5, -75)
  12. frame.BackgroundColor3 = Color3.fromRGB(125, 255, 255)
  13. frame.Active, frame.Draggable = true, true
  14.  
  15. -- Create Buttons
  16. local function createButton(text, pos, color, parent, size)
  17.     local btn = Instance.new("TextButton", parent)
  18.     btn.Size = size or UDim2.new(0, 120, 0, 30)
  19.     btn.Position = pos
  20.     btn.BackgroundColor3 = color
  21.     btn.Text = text
  22.     return btn
  23. end
  24.  
  25. -- Repositioned Buttons on the Frame
  26. local spawnoneButton = createButton("เปิดออโต้วาปเก็บของ", UDim2.new(0.1, 0, 0.1, 0), Color3.fromRGB(255, 255, 255), frame)
  27. local collectItemsButton = createButton("เปิดเก็บเข้าเป๋า", UDim2.new(0.1, 0, 0.3, 0), Color3.fromRGB(0, 255, 0), frame)
  28. local autoSomTamButton = createButton("เปิดออโต้ส้มตำ", UDim2.new(0.1, 0, 0.5, 0), Color3.fromRGB(255, 165, 0), frame)
  29. local minimizeButton = createButton("ย่อเมนู", UDim2.new(0.1, 0, 0.7, 0), Color3.fromRGB(255, 0, 0), frame)
  30.  
  31. -- Smaller openButton to toggle frame visibility
  32. local openButton = createButton("เปิด", UDim2.new(0.02, 0, 0.02, 0), Color3.fromRGB(125, 255, 125), gui, UDim2.new(0, 60, 0, 20))
  33. openButton.Visible = false
  34.  
  35. -- Variables for Collect and Auto Som Tam
  36. local isCollectingItems = false
  37. local collectItemsLoop
  38. local isAutoSomTamActive = false
  39. local autoSomTamLoop
  40.  
  41. -- Function to equip the item
  42. local replicatedStorage = game:GetService("ReplicatedStorage")
  43. local toolsFolder = replicatedStorage:WaitForChild("Tools"):WaitForChild("Items")
  44.  
  45. local function equipMatchingItem()
  46.     local backpack = player:WaitForChild("Backpack")
  47.    
  48.     -- Loop through all items in the Tools.Items folder
  49.     for _, item in ipairs(toolsFolder:GetChildren()) do
  50.         local itemName = item.Name
  51.  
  52.         -- Check if the item exists in the backpack
  53.         local backpackItem = backpack:FindFirstChild(itemName)
  54.  
  55.         if backpackItem then
  56.             -- Equip the item
  57.             player.Character.Humanoid:EquipTool(backpackItem)
  58.  
  59.             -- Fire the network event with the item name
  60.             replicatedStorage.Modules.NetworkFramework.NetworkEvent:FireServer("fire", nil, "AddInventory", itemName)
  61.             return -- Exit after equipping the first matching item
  62.         end
  63.     end
  64.  
  65.     warn("No matching item found in Backpack.")
  66. end
  67. -- Collect Items Button functionality
  68. collectItemsButton.MouseButton1Click:Connect(function()
  69.     isCollectingItems = not isCollectingItems
  70.     collectItemsButton.Text = isCollectingItems and "ปิดเก็บเข้าเป๋า" or "เปิดเก็บเข้าเป๋า"
  71.  
  72.     if isCollectingItems then
  73.         collectItemsLoop = game:GetService("RunService").Stepped:Connect(function()
  74.             equipMatchingItem()
  75.             wait(0.1) -- Wait time before the next loop iteration
  76.         end)
  77.     else
  78.         if collectItemsLoop then
  79.             collectItemsLoop:Disconnect()
  80.             collectItemsLoop = nil
  81.         end
  82.     end
  83. end)
  84.  
  85. -- Auto Som Tam Button functionality
  86. autoSomTamButton.MouseButton1Click:Connect(function()
  87.     isAutoSomTamActive = not isAutoSomTamActive
  88.     autoSomTamButton.Text = isAutoSomTamActive and "ปิดออโต้ส้มตำ" or "เปิดออโต้ส้มตำ"
  89.  
  90.     if isAutoSomTamActive then
  91.         autoSomTamLoop = game:GetService("RunService").Stepped:Connect(function()
  92.             local character = player.Character or player.CharacterAdded:Wait()
  93.             local backpack = player.Backpack
  94.  
  95.             local function teleportTo(part)
  96.                 character:SetPrimaryPartCFrame(part.CFrame)
  97.             end
  98.  
  99.             local function clickPart(part)
  100.                 local clickDetector = part:FindFirstChildOfClass("ClickDetector")
  101.                 if clickDetector then
  102.                     fireclickdetector(clickDetector)
  103.                 else
  104.                     warn("ClickDetector not found in the part.")
  105.                 end
  106.             end
  107.  
  108.             local function holdProximityPrompt(proximityPrompt)
  109.                 if proximityPrompt then
  110.                     proximityPrompt:InputHoldBegin()
  111.                     task.wait(1)
  112.                     proximityPrompt:InputHoldEnd()
  113.                 else
  114.                     warn("ProximityPrompt not found.")
  115.                 end
  116.             end
  117.  
  118.             local function checkAndAct()
  119.                 local workingVisible = character.Head.BillboardGui.Frame.Working.Visible
  120.                 local hasSomtamTool = backpack:FindFirstChild("Somtam ") or character:FindFirstChild("Somtam ")
  121.  
  122.                 if workingVisible then
  123.                     if not hasSomtamTool then
  124.                         teleportTo(workspace.Model.SomtumBase.Circle)
  125.                         clickPart(workspace.Model.SomtumBase.Circle)
  126.                     else
  127.                         local tool = backpack:FindFirstChild("Somtam ") or character:FindFirstChild("Somtam ")
  128.                         if tool then
  129.                             tool.Parent = character
  130.                             local npc = workspace.NPC_WORK:GetChildren()[math.random(1, #workspace.NPC_WORK:GetChildren())]
  131.                             teleportTo(npc.HumanoidRootPart)
  132.                             tool:Activate()
  133.                         end
  134.                     end
  135.                 else
  136.                     teleportTo(workspace.NPC.Somtum.HumanoidRootPart)
  137.                     holdProximityPrompt(workspace.NPC.Somtum.HumanoidRootPart.ProximityPrompt)
  138.                 end
  139.             end
  140.  
  141.             checkAndAct()
  142.             wait(0.1)
  143.         end)
  144.     else
  145.         if autoSomTamLoop then
  146.             autoSomTamLoop:Disconnect()
  147.             autoSomTamLoop = nil
  148.         end
  149.     end
  150. end)
  151.  
  152. -- Toggle Spawn
  153. local isSpawnOne = false
  154. spawnoneButton.MouseButton1Click:Connect(function()
  155.     isSpawnOne = not isSpawnOne
  156.     spawnoneButton.Text = isSpawnOne and "ปิดออโต้วาปเก็บของ" or "เปิดออโต้วาปเก็บของ"
  157.  
  158.     while isSpawnOne do
  159.         local part = game.Workspace.FX:FindFirstChild("XDRandom")
  160.         if part then
  161.             player.Character:SetPrimaryPartCFrame(part.CFrame)
  162.             fireclickdetector(part:FindFirstChildOfClass("ClickDetector"))
  163.         end
  164.         wait(0.1)
  165.     end
  166. end)
  167.  
  168. -- Minimize and Maximize Functions
  169. minimizeButton.MouseButton1Click:Connect(function()
  170.     frame.Visible = false
  171.     openButton.Visible = true
  172. end)
  173.  
  174. openButton.MouseButton1Click:Connect(function()
  175.     frame.Visible = true
  176.     openButton.Visible = false
  177. end)
  178.  
  179. -- Drag Function (for both mobile and PC)
  180. local function enableDragging(guiElement)
  181.     local dragging = false
  182.     local dragStart, startPos
  183.  
  184.     local function update(input)
  185.         local delta = input.Position - dragStart
  186.         guiElement.Position = UDim2.new(
  187.             startPos.X.Scale, startPos.X.Offset + delta.X,
  188.             startPos.Y.Scale, startPos.Y.Offset + delta.Y
  189.         )
  190.     end
  191.  
  192.     guiElement.InputBegan:Connect(function(input)
  193.         if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
  194.             dragging = true
  195.             dragStart = input.Position
  196.             startPos = guiElement.Position
  197.  
  198.             input.Changed:Connect(function()
  199.                 if input.UserInputState == Enum.UserInputState.End then
  200.                     dragging = false
  201.                 end
  202.             end)
  203.         end
  204.     end)
  205.  
  206.     guiElement.InputChanged:Connect(function(input)
  207.         if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
  208.             update(input)
  209.         end
  210.     end)
  211. end
  212.  
  213. -- Enable dragging for both frame and openButton
  214. enableDragging(frame)
  215. enableDragging(openButton)
Tags: Script
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement