ModuleScript referencing a ResetOnSpawn GUI

Hello! I have a module that references a Frame inside ScreenGui with ResetOnSpawn enabled. I first put it in ReplicatedStorage, but then I realized my mistake and moved it under StarterCharacterScripts. I think it isn’t the most appropriate place for a module as now I import this module like this:

local Players = game:GetService("Players")

local MyModule = require(Players.LocalPlayer.Character.Lib.MyModule)

That seems messy, because half of the modules is in ReplicatedStorage and the other half is inside the character model. Also, if I wanted to use this module outside of character scripts (e.g. player scripts, they don’t reset with the character) it will break.
So, how do I go about this? I could’ve dynamically accessed GUI in the module, but I want to tween a frame to make a fade-out effect and I don’t like creating tweens every time I need to apply this effect.

1 Like

You can pass the GUI Frame as an argument to the module’s functions or store it in a table upon initialization. That way you avoid hardcoding the Frame’s location, making the module reusable and independent of the character’s lifecycle.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.