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

How do I make a script that teleports a dead player into a certain position?

Asked by 10 years ago

I have no way how to make a script like that.

2 answers

Log in to vote
1
Answered by 10 years ago
game.Players["PlayerName"].Character.Humanoid.Died:connect(function()
    game.Players["PlayerName"].Character:MoveTo(Vector3.new(0,0,0));
end
Ad
Log in to vote
0
Answered by 10 years ago

@PiggyJingles just no, you then need to call it on every player MANUALLY, and the explanation? ._. You need to check on every player each tick (200 ms) if he's/she's dead, first create a LOCALSCRIPT and add a function like this:

local player = game.Players.LocalPlayer -- We define the local player
function teleportOnDeath()
    player.Position = Vector3.new(xCoord, yCoord, zCoord) -- Put instead of those arguments your integer number like (3, 5, 6)
end

After that we need to call it using the Died:connect(player) event, add this under everything:

player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(teleportOnDeath)
    end)
end)

That's it!

Answer this question