I was wondering how i would wait for a player to respawn and then teleport them to a certain position.I have tried this but it teleport them right when they die and just there torso.
Player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() if start == false then print("They have not pressed it") character.Torso.CFrame = CFrame.new(workspace.Lobby.Spawns.Part.Position) end end) end)
You already have a CharacterAdded
event, which fires every time a character is added to the player. A Died
event is not necessary, since CharacterAdded
fires when a player respawns, or gets a new character.
I'm assuming you have a 'Player' variable and a 'start' variable defined somewhere.
Player.CharacterAdded:connect(function(character) if start == false then print("They have not pressed it") character:WaitForChild("Torso").CFrame = CFrame.new(workspace.Lobby.Spawns.Part.Position) --The wait for child is just in case the torso is not loaded when the event fires, due to lag. end end)
Character isn't a thing,you have to do game.Players.Character
Here is the script
Player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() if start == false then print("They have not pressed it") game.Players.Character.Torso.CFrame = CFrame.new(workspace.Lobby.Spawns.Part.Position) end end) end)