LoadCharacter() Only working once

Hey Developers,
I’m making a thing where my developers have infinite lives in my story game. So that people don’t respawn, I set the respawn time to infinte on the players service.
However, the first time they die it works! They get respawned. But all the other times they stay dead; they don’t respawn. I have to use the developer console to load their characters.
I do not know the cause of this.
Here is my script:

local Developers = {1486279975, 1381724234, 144951476, 373301834,  309486350}

local MarketplaceService = game:GetService("MarketplaceService")
local diedEvent = game.ReplicatedStorage.DiedEvent
local reviveEvent = game.ReplicatedStorage.reviveEvent


function loadDiedFunction(player)
	player.Character.Humanoid.Died:connect(function()
		if table.find(Developers, player.UserId) then
			wait(2)
			player:LoadCharacter()
		else
			wait(1)
			diedEvent:FireClient(player)
		end
	end)
end

game.Players.PlayerAdded:Connect(function(player)
	player:LoadCharacter()
	loadDiedFunction(player)
end)

reviveEvent.OnServerEvent:Connect(function(player)
	player:LoadCharacter()
	loadDiedFunction(player)
end)

Thanks for any help! There are no errors.

Add a CharacterAdded function and see if that fixes your problem.

Add it where?..

game.Players.PlayerAdded:Connect(function(player)
	game.Players.CharacterAdded:Connect(function(char) -- fires everytime when the character is re-added to the game
    player:LoadCharacter()
loadDiedFunction(char) -- or player
end)
1 Like