Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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?

4 comments

0

use a remoteevent

0

Make sure that the script is in a correct place. And make sure that the character has loaded.

0

It's a localscript in Workspace, should it be somewhere else?

0

the player variable is missing

2 answers

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)

3 comments

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

0

What exactly does that mean? Sorry I'm just a bit confused

0

Teleporting the player can be done on the player’s client @stone

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

2 comments

0

Where should I insert that localscript?

0

Sorry for the late reply,I'm not quite sure but I think you need to put it in workspace.

This discussion is preserved as it was. New answers, comments, and votes are closed.