player.CharacterAdded:Wait() waits for the character to load, also you won’t need to wait in the script i gave you because it runs Everytime the character gets loaded in
I see you’re using Set and GetAttribute on the humanoid of the player, however once the player dies, the humanoid is reset and all of the attributes are removed. I would imagine that trying to get the attribute that doesnt exist, is stalling the script.
This isn’t a properly formatted and a recommended script, you are firing this event each time, the character respawns, this causes a function to pile up each time player dies
You should do this:
game.Players.PlayerAdded:Connect(function(player)
task.wait(1) until player.Character
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function(parameter)
-- Continue
end)
end)
Here the event fires when player joins, if they leave the game, you have to break the function to avoid memory leaks, or flooding errors in dev console
Maybe because the connection only applies to the current humanoid. After the humanoid dies and is removed from the game the connection disconnects and will not work for new humanoids.
You can use the CharacterAdded event, as shown in another reply, or reset the connection for every time a new humanoid is created.
The issue is now fixed, I combined your solutions. If you would like to know the new code:
plr.CharacterAdded:Connect(function(character)
local humanoid = character.Humanoid
if time == "Game" then
lives -= 1
if lives >= 0 then
wait(.2)
plr.Character.PrimaryPart.Position = gameSpawn.Position
speed(plr,250)
end
end
end)