I'm having a problem where an object value with a value equaled to the player's character doesn't recognize it when the player dies, therefore the character is destroyed. Even though the object doesn't exist, if I access the object through the object value instance it returns as if the character model exists. How can I fix this such that the object value's value become nil when the object doesn't exist any more.
COMMUNITY QUESTION
How to change the object value's value to nil when object is destroyed?
1 answer
Easy change it to nil
ObjectValue.Value = nil
or detect when object is destroyed do this
local Value = ObjectValue.Value
local partParent = Value.Parent
partParent.ChildRemoved:Connect(function(item)
if item == Value then
ObjectValue.Value = nil
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Welp you beat me to it