SHARE
TWEET

Better Vehicle Simulator AFK Autofarm

a guest Mar 25th, 2019 496 in 25 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Improved Vehicle Simulator AFK Autofarm:
  2.  
  3. --[[
  4. Fully automatic money/miles farm
  5. TODO:
  6. Add auto respawn vehicle
  7. ]]
  8. local waitTime = 3 --This will be the time it takes (seconds) until your car resets. See line 37
  9. --Do not change anything below :)
  10. local hint = Instance.new('Hint', Workspace) hint.Text = "Vehicle Simulator Autofarm loading..."
  11. local found = false
  12. local go = true
  13.  
  14. function findVehicle() --Finds your vehicle
  15.     while not found do --Loops until your vehicle has been found
  16.         local vehicles = Workspace.Vehicles:getChildren()
  17.         for i=1,#vehicles do
  18.             if vehicles[i]:findFirstChild'owner' then
  19.                 if vehicles[i].owner.Value == game:GetService'Players'.LocalPlayer.Name then -- Found your vehicle
  20.                     found                                 = true --Setting found to true so loop breaks
  21.                     vehicle                               = vehicles[i] -- Declares vehicle variable to your vehicle
  22.                     vehStats                              = vehicle.Handling -- Declares vehStats variable to vehicle stats folder
  23.                     vehStats.MaxSpeed.Value               = 800
  24.                     vehStats.Torque.Value                 = 35000
  25.                     vehStats.SteeringRadiusConstant.Value = 1200000000
  26.                 elseif vehicles[i + 1] == nil and not found then
  27.                     --Autorespawn would go here
  28.                     hint.Text = "Please spawn and enter your vehicle!" --Your vehicle does not exist in the Workspace
  29.                 end
  30.             end
  31.         end
  32.         wait(1) --Waiting before checking again so we don't crash
  33.     end
  34.     wait(2) --We've found the car. Waiting so the car can be properly placed on the highway
  35.     vehicle.PrimaryPart = vehicle.Chassis.VehicleSeat
  36. end
  37.  
  38. function farm() --This is where the magic happens :)
  39.     hint.Text = "Finished loading! Autofarm initialized."
  40.     while wait(waitTime) do --Waits x seconds before resetting car
  41.         vehicle:SetPrimaryPartCFrame(CFrame.new(-2470,60,777)) --Teleports vehicle to highway
  42.         game:GetService'VirtualUser':SetKeyUp("w") --Resets W key
  43.         game:GetService'VirtualUser':SetKeyDown("w") --Presses W key to go forward
  44.     end
  45. end
  46. findVehicle() --Calls the findVehicle function
  47. while go do
  48.     if not pcall(farm()) then --Calls farm function & checks for errors
  49.         found = false  --If it errors, it sets found to false and continues looking for your vehicle.
  50.         findVehicle()
  51.     end
  52. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top