Sharing variables between modules

Let’s say I have module A which inside of it has:

local gui = game.Players.LocalPlayer.MainGui
local frame = gui.Frame

frame.Visible = true

And then module B which inside of it has:

local gui = game.Players.LocalPlayer.MainGui
local frame = gui.Frame

frame.Visible = false

You can see the first two lines are repetitive, this is the case in many of my UI modules which gets some services and then variables such as PlayerGui.

Would it be better if in a different module I just have all the UI variables and services and then I call that module in module A and module B?

Any help is appreciated, thanks.

Yes this would be better if you are going to use them repeatedly. You can also make 1 module instead of multiple modules and place functions inside it.

Are there any downsides to doing this? I’ll probably do it in most client Ui code but all other code will follow the opposite route.

There is no downsides, it just depends on your way of formatting and organizing.