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

How teleport player to other place inside game when he dies?

Asked by 4 years ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.

When a player dies he will get teleported to an other place inside game

0
Use TeleportService() when player health = 0 or died. B_rnz 171 — 4y

2 answers

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

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
-- localscript in startergui
local position = Vector3.new() -- put in 3 number vector to where you want the player to go
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Died:Connect(function()
    wait(7)
    game.Players.LocalPlayer.Character.HumanoidRootPart.Position = position
end)

try that, im just moving the humanoidrootpart. Also, I am using wait to pause the player from spawning then teleporting. Hopefully your spawn time is 5 seconds, if not then change the wait, vectors are what is used to teleport the player.

Ad
Log in to vote
0
Answered by 4 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
local place = 000000 -- Put the id of the other place here
local Teleport = game:GetService('TeleportService')
game.Players.PlayerAdded:connect(function(Player)
Player.CharacterRemoving:connect(function()
Teleport:Teleport(place, Player)
end)
end)

If this fixed your problem, please upvote and accept this answer.

Answer this question