Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Requirements = require(script.Requirements)
- local SpawnCar = game.ReplicatedStorage.SpawnCar
- local Cars = game.ReplicatedStorage.Cars
- local Cooldown = {}
- SpawnCar.OnServerInvoke = (function(Player, Car)
- if Cooldown[Player.UserId] then
- return "Cooldown."
- end
- local NewCar
- local Pos
- local Success, Error = pcall(function()
- Cooldown[Player.UserId] = true
- if workspace.Cars:FindFirstChild(Player.UserId) then
- for _,Seat in ipairs(require(workspace.Cars[Player.UserId]).Seats or {}) do
- if Seat:IsA("Seat") or Seat:IsA("VehicleSeat") then
- if Seat.Occupant then
- Seat.Occupant.Jump = true
- end
- end
- end
- workspace.Cars[Player.UserId]:Destroy()
- end
- NewCar = Cars[Car.Car.Name]:Clone()
- local CarModule = require(NewCar)
- -- Color Plates
- local PlateColors = {
- ["Blue"] = "7183427655";
- ["Black"] = "7183070469";
- ["Red"] = "7183072561";
- }
- for _,v in ipairs(CarModule.Plate) do
- v.TextureID = "rbxassetid://"..PlateColors[Car.PlateColor]
- end
- local ColorParts
- if CarModule.Color then
- ColorParts = CarModule.Color
- end
- if not ColorParts then
- ColorParts = NewCar:GetChildren()[1].Body.Model.Color:GetChildren()
- end
- for _,v in ipairs(ColorParts) do
- v.Color = Car.CarColor
- end
- NewCar.Parent = workspace.Cars
- NewCar.Name = tostring(Player.UserId)
- Pos = CarModule.DriveSeat.Position
- Pos = Vector3.new(Pos.X,Pos.Y+10,Pos.Z)
- end)
- coroutine.wrap(function()
- pcall(function()
- wait(1.5)
- Player.Character:MoveTo(Pos)
- end)
- wait(6)
- Cooldown[Player.UserId] = nil
- end)()
- if not Success then
- warn(Error)
- if NewCar then
- pcall(function() NewCar:Destroy() end)
- end
- return "An Error Occured."
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement