SurfaceGui Adornee Changed event problem

Hello, I have a SurfaceGui in StarterGui and due to how my game works it’s adornee get set to nil then I set it back (because the Adornee get deleted then added again in the game). The problem is that when it get set to nil it doesn’t count as a change ? At the moment I’m using GetPropertyChangedSignal since it’s better when checking for only one property but it still doesn’t work. Is there a way to make the nil get counted as a change? I feel like it’s a bug but considering how nil works I’m not sure.

1 Like

AncestryChanged is what you are looking for here.

Doesn’t work, when my ScreenGui is set at the start of the server it works but when it’s Parent/Adornee get deleted it doesn’t launch the event (even tho the ancestry technically changed but it changed to nil and I think that’s the problem)

Can’t you just follow event driven programming here? There is a reason it gets patented to nil, during that action you then would do the thing you want done manually? Or does it HAVE to be a built-in signal?

The problem is that the event that parent it to nil is in a server script while the other a local script. I just didn’t want to do a remote event but I guess I have no choice since roblox doesn’t want to

I do find this strange as Parenting to nil does in fact fire the AncestryChanged event. Even if the parenting is done on the server, albeit as long as that is replicated to the client.

It does ? I’ll check again later then. Also when I say Parenting to nil I just means that the Parent get :Destroy so it get set to nil. Maybe it’s another type of nil when I do that and not the classic one ?

Destroy disconnects events(maybe doesn’t even bother setting Parent to nil) so that would probably be why. Wherever you delete the Parent in your code, just do a .Parent = nil on the SurfaceGui before Destroy perhaps?