Essentially, I have
ScreenGui.ResetOnSpawn set to
true, however, ModuleScripts that are required are still running long after they’re removed and the player has died.
I set one ModuleScript in question to print its parent and children, and its still running:
The print on top is the newest ModuleScript that was created after the player died and respawned, the print on the bottom is the old ModuleScript still running.
I just want confirmation if this is intended behavior because I’ve never ran into this issue until now. If it is, it’s amazing that I just now discovered it.
Module scripts aren’t independents scripts, they are running through the script you used to require them, so deleting them is not going to stop them.
Also i don’t see the point of deleting it, can’t you just require or recall it’s functions again once the player respawn ?
I don’t delete them; since ScreenGui.ResetOnSpawn is enabled, they’re automatically removed once the player dies.
For now, I just stop whatever function is running when its parent is nil. The script I use to require them is also in the same ScreenGui, which is why I’m more confused.
Edit: I’m just going to refactor my code and move the ModuleScripts to ReplicatedFirst
Oh okay, so i better understand now xD
Yeah, then it would be better if you can change it’s location to be in rep first ^^
After a bit of thinking I realized the problem was an RBXScriptConnection that was connected to an object in workspace, which was causing the ModuleScript’s method to continue to run even though it was no longer in the game.
So for this case, I think it was best that I moved the ModuleScripts to ReplicatedFirst.
It’s best to move all
ModuleScripts intended to be used locally to
ModuleScripts used by the server only,
ServerStorage is the most suitable.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.