When a player dies I want them to teleport to another game that is connected to the current game but it isn't working

Hey devs,
I’m trying to make a sciript that makes you get teleported to another game apart of the current game whenever you die. I have a local script in starter character scripts but the teleport part doesnt work. If anyone could help me, I would really appreciate it!

game.Players.LocalPlayer.Character:WaitForChild('Humanoid').Died:Connect(function()
	print("DIED")
	local FromChar = game.Players:GetPlayerFromCharacter(game.Players.LocalPlayer.Character.Parent)
	if FromChar then
		local TeleService = game:GetService("TeleportService")
		TeleService:Teleport(13884134530,FromChar)
	end
end)

What’s the point of doing this here? You are trying to find the Player from the LocalPlayer’s Character, when you already know the player? But you are even doing that wrong by using the parent of the Character(workspace)?

This code should work:

game.Players.LocalPlayer.Character:WaitForChild('Humanoid').Died:Connect(function()
	game:GetService("TeleportService"):Teleport(13884134530)
end)
2 Likes

oh ok, thanks for helping. im new to scripting so im still figuring things out

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.