How do I teleport a player to a brick, without getting an error?
Asked by
8 years ago Edited 8 years ago
I have a TextButton that when the player clicks, will teleport them to their car. In another script the car gets spawned into the game in the players folder located in Workspace. The "TeleportPlayer" is a brick in the body model of the car.
1 | script.Parent.MouseButton 1 Click:connect( function () |
3 | local playerfol = game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name .. "Car" ) |
4 | local player = game.Players.LocalPlayer |
5 | player.Character.Torso.CFrame = game.Workspace:FindFirstChild(playerfol.DefaultCar.Body.TeleportPlayer.CFrame) |
So I followed what the wiki said to set it up, and I believe it is correct, but I'm getting this error.
bad argument #3 to 'CFrame' (CFrame expected, got nil)
*I also added a slight wait between the car spawn and player teleport to give time for the model to spawn in correctly.
Any ideas on how to fix this?