Instead of teleporting me when I die, it teleports me as soon as I spawn n the game
ServerScript:
local GameId = 4950975351 game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(chr) local humanoid = chr:WaitForChild("Humanoid") if humanoid.Died then game:GetService('TeleportService'):Teleport(GameId, plr) end end) end)
humanoid.Died
is a function for whenever humanoids die. You cannot call it in an if statement. Instead, you're going to want to make a function for when the humanoid dies.
local gameId = 4950975351 game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) char:WaitForChild("Humanoid").Died:Connect(function() game:GetService('TeleportService'):Teleport(GameId, plr) end) end) end)
If this fails, then remove the PlayerAdded
and CharacterAdded
functions and insert the rest of the code into a localscript in StarterPlayerScripts. Add local plr = game.Players.LocalPlayer
below local gameId = 4950975351
instead.