Advertisement
NukeVsCity

Autofarm vehicle simulator

Aug 18th, 2020
3,848
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. local waitTime = 3 --This will be the time it takes (seconds) until your car resets. See line 37
  2. --Do not change anything below
  3. local hint = Instance.new('Hint', Workspace) hint.Text = "Vehicle Simulator Autofarm loading..."
  4. local found = false
  5. local go = true
  6.  
  7. function findVehicle() --Finds your vehicle
  8. while not found do --Loops until your vehicle has been found
  9. local vehicles = Workspace.Vehicles:getChildren()
  10. for i=1,#vehicles do
  11. if vehicles[i]:findFirstChild'owner' then
  12. if vehicles[i].owner.Value == game:GetService'Players'.LocalPlayer.Name then -- Found your vehicle
  13. found = true --Setting found to true so loop breaks
  14. vehicle = vehicles[i] -- Declares vehicle variable to your vehicle
  15. vehStats = vehicle.Handling -- Declares vehStats variable to vehicle stats folder
  16. vehStats.MaxSpeed.Value = 800
  17. vehStats.Torque.Value = 100000
  18. vehStats.SteeringRadiusConstant.Value = 120000000
  19. elseif vehicles[i + 1] == nil and not found then
  20. --Autorespawn would go here
  21. hint.Text = "Please spawn and enter your vehicle!" --Your vehicle does not exist in the Workspace
  22. end
  23. end
  24. end
  25. wait(1) --Waiting before checking again so we don't crash
  26. end
  27. wait(2) --We've found the car. Waiting so the car can be properly placed on the highway
  28. vehicle.PrimaryPart = vehicle.Chassis.VehicleSeat
  29. end
  30.  
  31. function farm() --This is where the magic happens
  32. hint.Text = "Finished loading! Autofarm initialized."
  33. while wait(waitTime) do --Waits x seconds before resetting car
  34. vehicle:SetPrimaryPartCFrame(CFrame.new(-2470,60,777)) --Teleports vehicle to highway
  35. game:GetService'VirtualUser':SetKeyUp("w") --Resets W key
  36. game:GetService'VirtualUser':SetKeyDown("w") --Presses W key to go forward
  37. end
  38. end
  39. findVehicle() --Calls the findVehicle function
  40. while go do
  41. if not pcall(farm()) then --Calls farm function & checks for errors
  42. found = false --If it errors, it sets found to false and continues looking for your vehicle.
  43. findVehicle()
  44. end
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement