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 when he dies ?

Asked by 6 years ago

If possible, when dying be teleported to a different world Thank you

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Hi Eds456oficial,

The humanoid has a .Died event that fires upon the death of it. I would just connect that to the TeleportService and make that work. Something along these lines would probably work:

local players = game:GetService("Players"); -- The players service
local teleport = game:GetService("TeleportService"); -- The teleport service
local id = 226039913; -- The id of the place, can be found in the url when you're on the page of the game.

players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        local hum = char:WaitForChild("Humanoid"); -- The humanoid of the character.

        hum.Died:Connect(function()
            teleport:Teleport(226039913, plr);
        end)
    end)
end)

Well, I hope I helped and have a nice day.

Thanks,

Best regards,

~~ KingLoneCat

0
Thx man Eds456oficial -10 — 6y
0
np KingLoneCat 2642 — 6y
0
Hey you want to play the game with me? I'll pay you 35 robux okay? Eds456oficial -10 — 6y
0
What game? KingLoneCat 2642 — 6y
View all comments (2 more)
0
FortNite Eds456oficial -10 — 6y
0
Sorry, I am not such a big fan of Fortnite, especially the one on Roblox. KingLoneCat 2642 — 6y
Ad

Answer this question