Hi! I wanted to make a race game but I don't know how to teleport players to their cars. Here's my local script located in starter player scripts(SPS) :
local car1 = workspace.minigames.carrace.cars["Formula F1"].DriveSeat
local car2 = workspace.minigames.carrace.cars["Formula F2"].DriveSeat
local car3 = workspace.minigames.carrace.cars["Formula F3"].DriveSeat
local car4 = workspace.minigames.carrace.cars["Formula F4"].DriveSeat
local car5 = workspace.minigames.carrace.cars["Formula F5"].DriveSeat
local car6 = workspace.minigames.carrace.cars["Formula F6"].DriveSeat
local car7 = workspace.minigames.carrace.cars["Formula F7"].DriveSeat
local car8 = workspace.minigames.carrace.cars["Formula F8"].DriveSeat
local playerModel = game.Players.LocalPlayer.Character
local humanoid = playerModel:WaitForChild("Humanoid")
if car1.Occupant == nil and not humanoid.Seated then
print("car1")
car1.Value = true
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = car1.Parent.CFrame
end
if car2.Occupant == nil and not humanoid.Seated then
print("car2")
car2.Value = true
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = car2.Parent.CFrame
end
if car3.Occupant == nil and not humanoid.Seated then
print("car3")
car3.Value = true
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = car3.Parent.CFrame
end
if car4.Occupant == nil and not humanoid.Seated then
print("car4")
car4.Value = true
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = car4.Parent.CFrame
end
if car5.Occupant == nil and not humanoid.Seated then
print("car5")
car5.Value = true
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = car5.Parent.CFrame
end
if car6.Occupant == nil and not humanoid.Seated then
print("car6")
car6.Value = true
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = car6.Parent.CFrame
end
if car7.Occupant == nil and not humanoid.Seated then
print("car7")
car7.Value = true
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = car7.Parent.CFrame
end
if car8.Occupant == nil and not humanoid.Seated then
print("car8")
car8.Value = true
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = car8.Parent.CFrame
end
the problem is that nothing works at all. (nothing prints or teleports) I thought the best way would be to check that the player is sitting and that the seat it is sitting on is occupied. Thanks for every answer :)

1 comment
The problem is that it's in a local script.