Has been a bug for a long time, probably just needs a check to see if the player has already respawned since it died.
Only occurs when Players.CharacterAutoLoads = true for obvious reasons
Might be nice to move this entire behaviour to lua to allow users to modify it e.g. in ServerScriptService (Slightly modified from this ):
local respawnTime = 5
local Players = game:GetService("Players")
Players.PlayerAdded:connect( function(Player)
Player.CharacterAdded:connect(function(Character)
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
if Humanoid then
Humanoid.Died:connect(function()
-- For backwards compatability of CharacterAutoLoads ( Users can now just override this script if they don't want auto loading )
if Players.CharacterAutoLoads == true then
wait(respawnTime)
--Check they are still alive and it's the same humanoid
if Player.Character == Character and Humanoid.Health <= 0 then
Player:LoadCharacter()
end
end
end)
end
end)
-- Make them spawn the first time
if Players.CharacterAutoLoads == true then
Player:LoadCharacter()
end
end)
I’m not sure if I’d classify that as an issue, considering, as you said, CharacterAutoLoads is true. I feel like the expected behavior would be that the system will attempt to force a respawn after a death occurred no matter what happens.
But…I can see how it would be beneficial if it checked to see if the character was currently alive before attempting it.
Although, for the last point, it would need to make sure it’s the same character else you could end up respawning before the 5 seconds is up if you reset, LoadCharacter and then reset again
That’s the problem – you can’t respawn a dead character. If you do, they’ll respawn a second time. You might suggest to let them wait it out, but if for instance I have a round-based game, I may want to respawn all players in the lobby immediately when the round ends, or the map when the round starts, so waiting isn’t an option. I think it makes more sense when you see the behavior in action:
First I reset, then I call LoadCharacter about 2 seconds after that, and then after I respawn, I respawn again 3 seconds later because ROBLOX’s spawn code respawns your character 5 seconds after it dies, unconditionally.
Going back to the round-based game, I respawn all players in the lobby. After I do that, whoever had died just before the round ended would spawn a second time in the lobby. I don’t want to have a custom spawn system – I just want to trigger respawning manually, so I don’t think writing my own spawn system is appropriate. ROBLOX’s spawn system should listen for LoadCharacter and cancel the default spawning if it’s called. That way, if I respawn someone after they die, they don’t spawn twice.
Seems like the character respawning automatically when it’s already been respawned manually is always undesired behavior. It seems reasonable to fix this, I’ll look into changing this behavior.
Normally it’s set to true, but you can set it to false. That’ll stop the “game” (C code) from loading the character when the player joins or when the character dies. Combine it with PlayerAdded, CharacterAdded and Humanoid.Died and you can create your own spawning system. has been done before, that property has been around for quite a while
EDIT: I’m still selectively blind at times (more like selectively not blind but eh)