Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- SETTINGS --
- local collectibleNames = {"Pear", "Banana", "Seed"}
- local autoCollect = false
- -- SERVICES --
- local Players = game:GetService("Players")
- local player = Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local root = character:WaitForChild("HumanoidRootPart")
- local Workspace = game:GetService("Workspace")
- -- GUI SETUP --
- local ScreenGui = Instance.new("ScreenGui", game.CoreGui)
- ScreenGui.Name = "EdibleCollectorGUI"
- local button = Instance.new("TextButton", ScreenGui)
- button.Size = UDim2.new(0, 180, 0, 40)
- button.Position = UDim2.new(0, 10, 0, 10)
- button.BackgroundColor3 = Color3.fromRGB(0, 170, 255)
- button.Text = "Auto Collect: OFF"
- button.TextSize = 18
- button.TextColor3 = Color3.new(1, 1, 1)
- button.BorderSizePixel = 0
- button.Active = true
- button.Draggable = true
- -- FUNCTION: Is collectible?
- local function isCollectible(item)
- for _, keyword in pairs(collectibleNames) do
- if string.lower(item.Name):find(string.lower(keyword)) then
- return true
- end
- end
- return false
- end
- -- FUNCTION: Teleport item to player
- local function collect(item)
- pcall(function()
- item.CFrame = root.CFrame + Vector3.new(0, 3, 0)
- end)
- end
- -- LOOP: Scan every 0.5 sec
- task.spawn(function()
- while true do
- if autoCollect then
- for _, obj in pairs(Workspace:GetDescendants()) do
- if obj:IsA("BasePart") and isCollectible(obj) then
- collect(obj)
- end
- end
- end
- task.wait(0.5)
- end
- end)
- -- NEW ITEM DETECTION
- Workspace.DescendantAdded:Connect(function(obj)
- if obj:IsA("BasePart") and isCollectible(obj) then
- repeat task.wait() until autoCollect and root -- wait until ready
- collect(obj)
- end
- end)
- -- BUTTON TOGGLE
- button.MouseButton1Click:Connect(function()
- autoCollect = not autoCollect
- button.Text = "Auto Collect: " .. (autoCollect and "ON" or "OFF")
- button.BackgroundColor3 = autoCollect and Color3.fromRGB(0, 200, 0) or Color3.fromRGB(0, 170, 255)
- end)
Advertisement
Add Comment
Please, Sign In to add comment