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

Teleporting upon Dieing! please Help?

Asked by
chadw 5
9 years ago

I am creating a Game Universe that is base on survival. That at lobby it will random select players and send them to different games which are survival maps. Right now i don't know how to create a script that once a player dies they will be sent back to the lobby game. Please help me!

I still trying to learn how to script right now on scale of 1 to 10 i say i am at 1 right now.

The way i wanted the script is once player health reach 0 wait 5 sec then place telaport back to game ID ####### which is where the lobby.

Can you guys Help me?

2 answers

Log in to vote
3
Answered by 9 years ago

Instead of waiting until the player's HP equals 0, just use the event Died from the player's humanoid.

Here is how to use it, along with the rest of the script:

Place_ID = 0 -- The ID of the lobby.

game.Players.PlayerAdded:connect(function(P) -- Get the player.
    P.CharacterAdded:connect(function(C) -- Get the persons character.
        C:WaitForChild('Humanoid').Died:connect(function() -- Died event here.
        wait(5)
        game:GetService('TeleportService'):Teleport(Place_ID, P) -- Teleport the player.
    end)
end)
end)

Put this in a server script.

Sources:

0
oh ok Thank You chadw 5 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

us the died event

0
use* User#600 0 — 9y
0
I upvoted your answer because it was correct, but you gave no information behind it as to what it does and you didn't even provide a link to a wiki page. It is recommended you provide valid source and a example script of the event. M39a9am3R 3210 — 9y

Answer this question