I’m trying to detect when the character is removed in a localscript placed in the StarterCharacterScripts folder, but every method I have tried doesn’t seem to work. I’ve tried .Destroying, .ChildRemoved, .AncestryChanged, I even tried using a while loop to detect the changes. Nothing works. Is this an engine bug or am I missing something?
1 Like
LocalScripts
(or any script really…) do not run when they’re a descendant of nil. When a character is removed, the model’s parent gets set to nil, which causes the current thread in the LocalScript
to be terminated. This means whatever is inside of your AncestryChanged
, ChildRemoved
, Destroying
, or whatever other event will not run.
LocalScript inside of StarterPlayerScripts
:
local Player = game.Players.LocalPlayer
Player.CharacterRemoving:Connect(function(Character)
print(Character.Parent)
end)
You’re better off listening for this event in a LocalScript
that does not exist within the character model.
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.