Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- v2 by Skira
- local player = game.Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
- local chests = {}
- for _, obj in pairs(workspace:GetDescendants()) do
- if obj.Name == "Chest1" or obj.Name == "Chest2" or obj.Name == "Chest3" then
- table.insert(chests, obj)
- end
- end
- local screenGui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
- local title = Instance.new("TextLabel", screenGui)
- title.Size = UDim2.new(0, 400, 0, 30)
- title.Position = UDim2.new(0.5, -200, 0.7, -50)
- title.Text = "Chest Auto Farm by Skira"
- title.TextSize = 18
- title.TextColor3 = Color3.fromRGB(255, 255, 255)
- title.BackgroundTransparency = 1
- local button1 = Instance.new("TextButton", screenGui)
- button1.Size = UDim2.new(0, 80, 0, 30)
- button1.Position = UDim2.new(0.5, -140, 0.8, -40)
- button1.Text = "Chest1"
- button1.BackgroundColor3 = Color3.fromRGB(169, 169, 169)
- local button2 = Instance.new("TextButton", screenGui)
- button2.Size = UDim2.new(0, 80, 0, 30)
- button2.Position = UDim2.new(0.5, -50, 0.8, -40)
- button2.Text = "Chest2"
- button2.BackgroundColor3 = Color3.fromRGB(169, 169, 169)
- local button3 = Instance.new("TextButton", screenGui)
- button3.Size = UDim2.new(0, 80, 0, 30)
- button3.Position = UDim2.new(0.5, 40, 0.8, -40)
- button3.Text = "Chest3"
- button3.BackgroundColor3 = Color3.fromRGB(169, 169, 169)
- local autoFarmButton = Instance.new("TextButton", screenGui)
- autoFarmButton.Size = UDim2.new(0, 200, 0, 50)
- autoFarmButton.Position = UDim2.new(0.5, -100, 0.9, -25)
- autoFarmButton.Text = "OFF"
- autoFarmButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
- local TweenService = game:GetService("TweenService")
- local function moveToChest(chest)
- local distance = (chest.Position - humanoidRootPart.Position).magnitude
- local duration = distance / 300
- local targetPos = chest.Position + Vector3.new(0, 3, 0)
- local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Linear)
- local goal = {CFrame = CFrame.new(targetPos)}
- local tween = TweenService:Create(humanoidRootPart, tweenInfo, goal)
- tween:Play()
- tween.Completed:Wait()
- end
- local isOn = false
- local selectedChest = nil
- local lastTweenTime = 0
- local function toggleAutoFarm()
- if isOn then
- autoFarmButton.Text = "OFF"
- autoFarmButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
- isOn = false
- else
- autoFarmButton.Text = "ON"
- autoFarmButton.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
- isOn = true
- while isOn do
- local currentTime = tick()
- if selectedChest then
- moveToChest(selectedChest)
- else
- local randomChest = chests[math.random(1, #chests)]
- moveToChest(randomChest)
- end
- lastTweenTime = currentTime
- wait(1)
- end
- end
- end
- local function toggleChestSelection(chestIndex, button)
- if button.BackgroundColor3 == Color3.fromRGB(169, 169, 169) then
- button.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
- selectedChest = chests[chestIndex]
- else
- button.BackgroundColor3 = Color3.fromRGB(169, 169, 169)
- if selectedChest == chests[chestIndex] then
- selectedChest = nil
- end
- end
- end
- autoFarmButton.MouseButton1Click:Connect(toggleAutoFarm)
- button1.MouseButton1Click:Connect(function() toggleChestSelection(1, button1) end)
- button2.MouseButton1Click:Connect(function() toggleChestSelection(2, button2) end)
- button3.MouseButton1Click:Connect(function() toggleChestSelection(3, button3) end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement