Advertisement
Vanihgol33

AFTOFARM DON'T Press The button 4!

May 8th, 2023 (edited)
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.44 KB | None | 0 0
  1. local TweenService = game:GetService("TweenService")
  2. local Players = game:GetService("Players")
  3.  
  4. local player = Players.LocalPlayer
  5. local teleporting = false
  6. local coinName = "Coin"
  7.  
  8. local function findAllCoins()
  9.     local coins = {}
  10.     for _, part in ipairs(workspace:GetDescendants()) do
  11.         if part:IsA("BasePart") and part.Name == coinName then
  12.             table.insert(coins, part)
  13.         end
  14.     end
  15.     return coins
  16. end
  17.  
  18. local function teleportLoop()
  19.     while true do
  20.         if teleporting then
  21.             local character = player.Character
  22.             local humanoid = character and character:FindFirstChildOfClass("Humanoid")
  23.             local rootPart = character and character:FindFirstChild("HumanoidRootPart")
  24.  
  25.             if character and humanoid and rootPart then
  26.                 local coins = findAllCoins()
  27.                 if #coins > 0 then
  28.                     for _, coin in ipairs(coins) do
  29.                         if not teleporting then break end
  30.                         rootPart.CFrame = CFrame.new(coin.Position + Vector3.new(0, 3, 0))
  31.                         humanoid:Move(Vector3.new(1, 0, 0), true)
  32.                         humanoid.Jump = true
  33.                         wait(0.15)
  34.                     end
  35.                 end
  36.             end
  37.         end
  38.         wait(0.15)
  39.     end
  40. end
  41.  
  42. task.spawn(teleportLoop)
  43.  
  44. local screenGui = Instance.new("ScreenGui")
  45. screenGui.ResetOnSpawn = false
  46. screenGui.Parent = game.CoreGui
  47.  
  48. local frame = Instance.new("Frame")
  49. frame.Size = UDim2.new(0, 200, 0, 100)
  50. frame.Position = UDim2.new(0.5, -100, 0.5, -50)
  51. frame.BackgroundColor3 = Color3.new(0, 0, 0)
  52. frame.BorderSizePixel = 0
  53. frame.Active = true
  54. frame.Draggable = true
  55. frame.Parent = screenGui
  56. frame.Visible = false
  57. frame.ClipsDescendants = true
  58. frame.BackgroundTransparency = 1
  59.  
  60. local corner = Instance.new("UICorner")
  61. corner.CornerRadius = UDim.new(0, 15)
  62. corner.Parent = frame
  63.  
  64. local titleBar = Instance.new("TextLabel")
  65. titleBar.Size = UDim2.new(1, 0, 0, 20)
  66. titleBar.Position = UDim2.new(0, 0, -0.25, 0)
  67. titleBar.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2)
  68. titleBar.Text = "Auto farm by Vinihgol333"
  69. titleBar.TextColor3 = Color3.new(1, 1, 1)
  70. titleBar.TextScaled = true
  71. titleBar.Font = Enum.Font.SourceSansBold
  72. titleBar.Parent = frame
  73.  
  74. local titleCorner = Instance.new("UICorner")
  75. titleCorner.CornerRadius = UDim.new(0, 10)
  76. titleCorner.Parent = titleBar
  77.  
  78. local textSizeConstraint = Instance.new("UITextSizeConstraint")
  79. textSizeConstraint.MinTextSize = 8
  80. textSizeConstraint.MaxTextSize = 14
  81. textSizeConstraint.Parent = titleBar
  82.  
  83. local button = Instance.new("TextButton")
  84. button.Size = UDim2.new(0, 80, 0, 40)
  85. button.Position = UDim2.new(0.5, -40, 0.5, -20)
  86. button.BackgroundColor3 = Color3.new(0, 1, 0)
  87. button.Text = "ON"
  88. button.TextColor3 = Color3.new(1, 1, 1)
  89. button.Font = Enum.Font.SourceSansBold
  90. button.TextSize = 18
  91. button.Parent = frame
  92.  
  93. local buttonCorner = Instance.new("UICorner")
  94. buttonCorner.CornerRadius = UDim.new(0, 10)
  95. buttonCorner.Parent = button
  96.  
  97. local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
  98. local fadeIn = TweenService:Create(frame, tweenInfo, {BackgroundTransparency = 0})
  99. frame.Visible = true
  100. fadeIn:Play()
  101.  
  102. button.MouseButton1Click:Connect(function()
  103.     teleporting = not teleporting
  104.     button.Text = teleporting and "OFF" or "ON"
  105.     button.BackgroundColor3 = teleporting and Color3.new(1, 0, 0) or Color3.new(0, 1, 0)
  106. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement