Do Functions in ScreenUI gets disconnects automatically?

Event Functions at ScreenUI do disconnects after calling Player:LoadCharacter()?

Please remind me if this post is a duplicated. Thx!

I’m not sure what you’re trying to say, but if I can assume right, are trying to say if Events are disconnected if you Load the character?

The answer is no, technically. If you have it so the Gui ResetsOnSpawn, it will technically make the script again and connect the events, if the script with those events is in a ScreenGui with ResetOnSpawn enabled. But if ResetOnSpawn is disabled, the script wont be remade, meaning the events don’t get disconnected for that ScreenGui

The issue comes if you have local variables for the player’s character, which will cause issues with the character being nil on a respawn/reload.

But to answer yuor question, they do get disconnected but immediately reconnected, but reset of events depends on the location of the Script itself

1 Like

That means do I’ve to disconnect it upon player died?

Again, it depends on your script’s location. I’m still not understand what you’re trying to get at, could you give an example. I don’t think you’d have to disconnect anything

Connections to events on instances are automatically disconnected when they’re destroyed.

Calling Player:LoadCharacter doesn’t set up any connections, so there’s nothing to be cleaned up manually or automatically.

It’ll be a lot easier to know what you mean if you post some code samples

1 Like