Hello,
I’m trying to make a script that will trigger different functions when it is moved between the player and the player’s character. My issue is that script.AncestryChanged only fires when the script is moved to the player, which keeps me from detecting when the script is moved to the character. I have tried ‘GetPropertyChangedSignal’, but it only detects when the script has been moved to the character. I could use them together but I want to learn what I’m doing wrong, or if there is a better method.
Use .ChildAdded or .ChildRemoved
https://developer.roblox.com/en-us/api-reference/event/Instance/ChildAdded
Character.ChildAdded:Connect(function(script)
end)
This works perfectly fine for me when swapping it between player-character:
script.AncestryChanged:Connect(function(obj)
print(obj.Parent)
end)
consider adding more information to your topic so we can help further.
i tried that exact script, still only detecting one of the events
that might work, but in my circumstance, its the script being added and removed, so this wouldn’t work well