I am trying to get my spawn in my game working but as soon as I click the button to get teleported and the countdown reaches 0 I get this error and don't get teleported to this new location in the map.
repeat wait() until Player.Character:FindFirstChild("Torso") Player.Character.Torso.Anchored = true Player.Character.Torso.CFrame = CFrame.new(Vector3.new(-21.3, 15019, -44.1));--teleobject.CFrame local bodyVel = Player.Character.Torso:FindFirstChild("BodyAnchor") bodyVel.maxForce = Vector3.new(5000000,5000000,5000000) bodyVel.D = 1000 bodyVel.P = 10000 bodyVel.position = Workspace.Scenery:WaitForChild("ReturnPad").Position Player.Character.Torso.Anchored = false Player.Character.Torso.CFrame = CFrame.new(math.random(Workspace.Scenery.ReturnPad.Position.X-10,Workspace.Scenery.ReturnPad.Position.X+10),Workspace.Scenery.ReturnPad.Position.Y,math.random(Workspace.Scenery.ReturnPad.Position.Z-10,Workspace.Scenery.ReturnPad.Position.Z+10)) for i = 0, 1, 0.05 do wait()
When you load a game, all the scripts load before the objects, so instead of :FindFirstChild()
, use :WaitForChild()