Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i teleport a player after they have died?

Asked by 9 years ago

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)

2 answers

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

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)
0
When i try this in studio the players torso does not go to the location raspyjessie 117 — 9y
0
Read it now Perci1 4988 — 9y
Ad
Log in to vote
-2
Answered by 9 years ago

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)
0
That is incorrect. Perci1 4988 — 9y
0
Why does everyone -1 my questions :( Because i have 100 questions that has a code that isn't even close to being right i quit scripting helpers time to keep learning how to script on wikihow iluvmaths1123 198 — 9y
0
And also tell the creator of scripting helpers i'm quitting and learning how to script on wikihow iluvmaths1123 198 — 9y
0
Your script is completely incorrect on line 06 and you did not help to fix the problem at all, therefore was downvoted. Perci1 4988 — 9y
0
maybe shut the hell up iluvmaths1123 198 — 7y

Answer this question