local Car = game.Workspace.Car1 -- Car1 is the name of your car in workspace.
local Seats = Car.Seats:GetChildren() -- You should have a model called "Seats" in the Car model.
local Gui = script.Parent:FindFirstChild("ExitGui") -- In your CarTP (The part this script is in), you should have a ScreenGui called "ExitGui".
local Gui2 = script.Parent:FindFirstChild("LoadingScreen") -- In your CarTP (The part this script is in), you should have a ScreenGui called "LoadingScreen".
local TeleportService = game:GetService("TeleportService")
local GameId = 0 -- Change to your placeID.
local PlayersInCar = {}
local debounce = false
-- You shouldn't have to touch anything below unless you're having bugs.
script.Parent.Touched:Connect(function(hit)
if debounce then return end
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
for i, v in pairs(Seats) do
if Seats.Occupant == nil then
local Check = Instance.new("Weld")
Check.Name = "Check"
Check.Parent = player.Character
Check.Parent.Humanoid.JumpPower = 0
Check.Parent.Humanoid.WalkSpeed = 0
end
end
Gui:Clone().Parent = player.PlayerGui
Seats[math.random(1, #Seats)]:Sit(player.Character.Humanoid)
wait(10)
if player.Character:FindFirstChild("Check") then
debounce = true
local Game = TeleportService:ReserveServer(GameId)
table.insert(PlayersInCar, player)
if player.PlayerGui:FindFirstChild("ExitGui") then
player.PlayerGui.ExitGui:Destroy()
end
for i = 1, 100 do -- Moves car forward 100 studs.
Car:TranslateBy(Vector3.new(0, 0, -1))
wait()
end
Gui2:Clone().Parent = player:FindFirstChild("PlayerGui")
TeleportService:TeleportToPrivateServer(GameId, Game, PlayersInCar)
wait(10)
for i = 1, 100 do -- Moves car back.
Car:TranslateBy(Vector3.new(0, 0, 1))
wait()
end
wait(3)
debounce = false
end
end)