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?
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)
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