UsernameRTX

Driving Simulator Simple Race Auto-farm

Apr 27th, 2021
1,376
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2. local Players = game:GetService("Players")
  3.  
  4. local LocalPlayer = Players.LocalPlayer
  5. local Vehicle = (function()
  6.     for Number, Instance2 in pairs(workspace["$cars"]:GetChildren()) do
  7.         if Instance2.State.Owner.Value == LocalPlayer then
  8.             return Instance2
  9.         end
  10.     end
  11.     return
  12. end)()
  13. local ResetVelocity = function(Model)
  14.     for Number, Instance2 in pairs(Model:GetDescendants()) do
  15.         if Instance2.ClassName == "Part" then
  16.             Instance2.Velocity = Vector3.new(0, 0, 0)
  17.             Instance2.RotVelocity = Vector3.new(0, 0, 0)
  18.         end
  19.     end
  20.     return
  21. end
  22.  
  23. local Name = "Downtown Race"
  24. local Boolean = false
  25. local PrimaryBody = Vehicle.Body.PrimaryBody
  26.  
  27. local Part = Instance.new("Part")
  28. Part.CFrame = CFrame.new(0, workspace.FallenPartsDestroyHeight, 0)
  29. Part.Anchored = true
  30. Part.Size = Vector3.new(PrimaryBody.Size.X, 1, PrimaryBody.Size.Z)
  31. Part.Parent = workspace
  32.  
  33. LocalPlayer.PlayerGui.Races.ChildAdded:Connect(function(ChildAdded)
  34.     if ChildAdded.Name == "HudContainer" then
  35.         Boolean = true
  36.     end
  37. end)
  38.  
  39. LocalPlayer.PlayerGui.Races.ChildRemoved:Connect(function(ChildRemoved)
  40.     if ChildRemoved.Name == "HudContainer" then
  41.         Boolean = false
  42.         ResetVelocity(Vehicle)
  43.         Vehicle:SetPrimaryPartCFrame(Part.CFrame + Vector3.new(0, PrimaryBody.Size.Y / 2 + Part.Size.Y / 2, 0))
  44.     end
  45. end)
  46.  
  47. ResetVelocity(Vehicle)
  48. Vehicle:SetPrimaryPartCFrame(Part.CFrame + Vector3.new(0, PrimaryBody.Size.Y / 2 + Part.Size.Y / 2, 0))
  49. ReplicatedStorage.remotes.races.RaceNotifier:Destroy()
  50. while wait() do
  51.     if Boolean then
  52.         for Number, Instance2 in pairs(workspace["$raceColliders"][Name]:GetChildren()) do
  53.             if Instance2.ClassName == "Part" and Boolean then
  54.                 Vehicle:SetPrimaryPartCFrame(Instance2.CFrame)
  55.                 wait(.25)
  56.             end
  57.         end
  58.     end
  59.     ReplicatedStorage.remotes.races.SignalInterest:FireServer(Name)
  60. end
RAW Paste Data