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

TeleportService script isn't working, can somebody please tell me what's wrong with it?

Asked by 6 years ago

I'm making a system where there's a start place (the lobby place) and the game place and when somebody dies in the game place, they will teleport back to the lobby place. I tried making a script for this but it doesn't seem to work and my script analysis/output isn't telling me anything:

game.Players.LocalPlayer.Character:WaitForChild('Humanoid').Died:connect(function()

game:GetService('TeleportService'):Teleport(2094965912)

end)

Can someone please tell me what's wrong?

0
use a remoteevent PropzFx 27 — 6y
0
Make sure that the script is in a correct place. And make sure that the character has loaded. Chiken983 15 — 6y
0
It's a localscript in Workspace, should it be somewhere else? TrixitesWasTaken 13 — 6y
0
the player variable is missing NinjaTeam_NT 2 — 5y

2 answers

Log in to vote
0
Answered by 6 years ago

You gotta define the player to be teleported so

local player = game.Players.LocalPlayer

player.Character.Humanoid.Died:connect(function()
    game:GetService('TeleportService'):Teleport(2094965912,player)
end)
0
It also needs to be done on the server so you'll have to either use the server in the first place or use an event StoneFox_Alfa 5 — 6y
0
What exactly does that mean? Sorry I'm just a bit confused TrixitesWasTaken 13 — 6y
0
Teleporting the player can be done on the player’s client @stone Thegrimdeathzombie 40 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

I am not so sure about scripting cause I am a average scripter but I think you need to make the local script know that if the player has died,it needs to teleport the player to the other place

Just like StoneFox_Alfa's script,try using variables to make the script cleaner. I'm not too sure about his/her explanation,but I also think that you need to make the script identify what

Example.

game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
       TeleportService:Teleport(2094965912, player)
    end)
end)
end)

Hope this works!If it doesn't then reply me.I'll try my best! And if this doesn't work try using roblox wiki.It's a life saver!

Here's the articles Humanoid.Died: www.robloxdev.com/api-reference/event/Humanoid/Died TeleportService: www.robloxdev.com/articles/Teleporting-Between-Places

0
Where should I insert that localscript? TrixitesWasTaken 13 — 6y
0
Sorry for the late reply,I'm not quite sure but I think you need to put it in workspace. rochel89 42 — 6y

Answer this question