My question is linked to this one Calling :LoadCharacter( ) on a dead character causes them to respawn twice
Basically, I have a script that at the start of the game replaces the player’s character with a custom character. Upon pressing ‘q’, the character is killed and manually respawned again as the custom character.
local Players = game:GetService("Players")
local event = game.ReplicatedStorage.RemoteEvent
function loadCustomChar(player)
local char = game.ReplicatedStorage.Pumpkin:Clone()
char.Name = player.Name
player.Character = char
char.Parent = workspace
end
function onPlayerAdded(player)
wait(5)
loadCustomChar(player)
end
Players.PlayerAdded:Connect(onPlayerAdded)
function killplayer(player)
player.Character.Humanoid.Health = 0
wait(2)
loadCustomChar(player)
end
event.OnServerEvent:Connect(killplayer)
However, after ‘manually’ respawning the player, the default Roblox repawn system also respawns the character again. Even if I call player:LoadCharacter()
before attempting to load the custom character, the issue persists.
I am wondering how the default respawn system works. If I call player:LoadCharacter()
in the function killplayer without changing the character, then this issue does not occur, which leads me to believe there must be something about the character I am trying to set that is causing the issue.
function killplayer(player)
player.Character.Humanoid.Health = 0
wait(2)
player:LoadCharacter()
end
This is the custom character:
Any help on this is greatly appreciated. I know I can disable CharacterAutoLoads, but I am not sure why this shouldn’t work.
Update: Interestingly, if I add a part to the custom character called Torso, this issue does not occur. Is this the expected behaviour?