TotallyGames

Call Scrtipt

Feb 17th, 2024
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.79 KB | Source Code | 0 0
  1. local player = game.Players.LocalPlayer
  2. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  3. local SpawnCarEvent = ReplicatedStorage:WaitForChild("SpawnCar")
  4. local DeleteCarEvent = ReplicatedStorage:WaitForChild("DeleteCar")
  5. local carName = script.Parent.Name
  6. local SpawnCarFrame = script.Parent.Parent
  7.  
  8. script.Parent.MouseButton1Down:Connect(function()
  9.     SpawnCarFrame.Visible = false
  10.     local CurrentCar = game.Workspace:FindFirstChild(player.Name .. 'sCar')
  11.     if not CurrentCar then
  12.         SpawnCarEvent:FireServer(carName)
  13.     else
  14.         if player.Character.Humanoid.SeatPart ~= nil and player.Character.Humanoid.SeatPart:IsA("VehicleSeat") then
  15.             player.Character.Humanoid.Sit = false
  16.         end
  17.         wait()
  18.         DeleteCarEvent:FireServer(CurrentCar)
  19.         SpawnCarEvent:FireServer(carName)
  20.     end
  21. end)
Add Comment
Please, Sign In to add comment