I want to use LoadCharacter on a player’s character when they die. Instead, I get this error:
Here is my code:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
hum:GetPropertyChangedSignal("Health"):Connect(function()
if hum.Health == 0 then
wait(2)
plr:LoadCharacter()
print("Loading character...")
end
end)
end)
end)
the error shouldn’t affect the outcome of the script, however, to get rid of it just a second argument to WaitForChild with any int, it will make a timeout. If you don’t want a timeout then ignore the error.
TL;DR: character is destroyed but the wait for child is still searching for a humanoid within this destroyed character model.
Additionally, @Thalryxen should disable character auto load like the example script provided in the documentation to avoid character loading conflict with the default spawn system.