#How to use module scripts with UI's

1 messages · Page 1 of 1 (latest)

lone shore
#

I am a developing creator and am actively trying to break away from local and server scripts and into the reusable module scripts.

I want to use GUI in my games along with these module scripts but when i run one of my module scripts from outside of starter GUI (for example in starter player scripts or replicated storage) any actions with starter GUI is ignored (only works when the scrip is inside of starter gui). I am assuming i should be grabbing the GUI that i put into starter gui from the player but i do not know how to do that while keeping my module scripts within replicated storage.

I want to be able to learn to use a more flexible style of developing so if anyone has or knows a solution it would be very appreciated.

#

examples are heavily appreciated

coarse cradle
lone shore
#

you do not have to write any code for me, i will not use it in my game

coarse cradle
#

modulescripts can be placed anywhere

#

you also cannot escape the local and server scripts, you need at least one of each to execute at least one modulescript which may execute more - this is known as single script architecture and it's one way to do things

#

in fact, to run everything the roblox api offers, you actually need 2 server scripts configured correctly, but that's an advanced technique that probably isn't relevant at your stage. start with the basics.

lone shore
#

alright, btw i can grab the player GUI as a property through the player right?

coarse cradle
#

you can examine stuff like this by pressing play in studio and looking through the explorer

#

roblox adds and moves a couple of things that do not appear while editing

#

such as the PlayerModule

#

and player.StarterGear

#

and player.Character.Animate

#

and player.Character.Health

#

basically, if you can do something manually from the explorer, you can write a script to do the same thing but automated and much faster

lone shore
#

got it, thank you for the help

coarse cradle
#

and always refer to the docs first, it will likely answer most of your first questions about how something works:
https://create.roblox.com/docs/reference/engine/classes/StarterGui
or it might even teach you things you weren't aware of:
https://create.roblox.com/docs/reference/engine/classes/StarterPlayer

Additionally, you may add four objects to this service (StarterPlayer):

A StarterPlayerScripts instance with scripts that run once for each player.
A StarterCharacterScripts instance with scripts to add to each player's character every time they spawn.
A Humanoid instance named StarterHumanoid which will be used as the default humanoid for each player's character.
A Model instance named StarterCharacter which will be used as the character model for all players.