Advertisement
Alexplazz

Untitled

Nov 6th, 2021
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. local Requirements = require(script.Requirements)
  2. local SpawnCar = game.ReplicatedStorage.SpawnCar
  3. local Cars = game.ReplicatedStorage.Cars
  4.  
  5. local Cooldown = {}
  6.  
  7. SpawnCar.OnServerInvoke = (function(Player, Car)
  8. if Cooldown[Player.UserId] then
  9. return "Cooldown."
  10. end
  11. local NewCar
  12. local Pos
  13. local Success, Error = pcall(function()
  14. Cooldown[Player.UserId] = true
  15. if workspace.Cars:FindFirstChild(Player.UserId) then
  16. for _,Seat in ipairs(require(workspace.Cars[Player.UserId]).Seats or {}) do
  17. if Seat:IsA("Seat") or Seat:IsA("VehicleSeat") then
  18. if Seat.Occupant then
  19. Seat.Occupant.Jump = true
  20. end
  21. end
  22. end
  23. workspace.Cars[Player.UserId]:Destroy()
  24. end
  25. NewCar = Cars[Car.Car.Name]:Clone()
  26. local CarModule = require(NewCar)
  27. -- Color Plates
  28. local PlateColors = {
  29. ["Blue"] = "7183427655";
  30. ["Black"] = "7183070469";
  31. ["Red"] = "7183072561";
  32. }
  33. for _,v in ipairs(CarModule.Plate) do
  34. v.TextureID = "rbxassetid://"..PlateColors[Car.PlateColor]
  35. end
  36.  
  37. local ColorParts
  38. if CarModule.Color then
  39. ColorParts = CarModule.Color
  40. end
  41. if not ColorParts then
  42. ColorParts = NewCar:GetChildren()[1].Body.Model.Color:GetChildren()
  43. end
  44. for _,v in ipairs(ColorParts) do
  45. v.Color = Car.CarColor
  46. end
  47.  
  48. NewCar.Parent = workspace.Cars
  49. NewCar.Name = tostring(Player.UserId)
  50. Pos = CarModule.DriveSeat.Position
  51. Pos = Vector3.new(Pos.X,Pos.Y+10,Pos.Z)
  52. end)
  53. coroutine.wrap(function()
  54. pcall(function()
  55. wait(1.5)
  56. Player.Character:MoveTo(Pos)
  57. end)
  58. wait(6)
  59. Cooldown[Player.UserId] = nil
  60. end)()
  61. if not Success then
  62. warn(Error)
  63. if NewCar then
  64. pcall(function() NewCar:Destroy() end)
  65. end
  66. return "An Error Occured."
  67. end
  68. end)
  69.  
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement