Hey, Ive been confused on something which i need help on.
for example the players camera follows the mouse slightly when a starter gui is opened. I know how to make both scripts, but i want to only let the camera follow mouse script run when the gui is opened and to stop running when a button is pressed and the gui closes.
also this could be anything not just the example above
I thought of using global variables like booleans but i want to know if there is another way
it may sound stupid but if anyone knows the answer i would appreciate it
If the script that controls the players camera following the mouse is run as a loop (while ... do / RunService.Heartbeat / etc.), you can add an if statement that checks if the gui is enabled.
It would be helpful to see your current code to know how you are handling everything, it is also good practice and a tad bit easier to keep everything contained within one script per interface.
Your right about that, but im also talking in general not just this situation
like maybe something like a storyline, for example
quest 1- defeat 5 thugs
quest 2 - after defeating 5 thugs you come back to the npc and he gives you another quest
quest 3 - after finishing quest 2 a cutscene happens and you get teleported
quest 4 etctetcetc
and so on if the quest amount is wayy more like 100 and i want them to be handed out to the player in numerical order how would i do that. And how would i sort it out
Another approach is to use BindableEvents, which are basically custom events that scripts can listen to. Fire the BindableEvent associated with an event once a certain condition tied to that event is met. Note that this is really only appropriate when using meaningful data on the server side since conditions can be spoofed on the client - if you need to fire an event for the player on the client using server-side validation, a RemoteEvent is appropriate.
If the condition is just when a button is pressed or something irrelevant to possible exploitation, you can use BindableEvents on the client. Fire the event once the UI is opened to tell the camera script to run, and fire it again to let it know it’s closed. You could also just listen for the events associated with the UI button, since most UI elements have built-in events for when they are activated.
So if the player joins the game the starter menu opens, and i fire the bindable event to make the camera follow the players mouse and when the gui is closed will i fire it again and use booleans to disconnect the event?
ill look more into bindable events and functions but would i use a bunch of bindable events since i want it in order into something like the quest system i mentioned with many scripts?
So if the player joins the game the starter menu opens, and i fire the bindable event to make the camera follow the players mouse and when the gui is closed will i fire it again and use booleans to disconnect the event?
Just use the built in event that whatever button that controls the starter button uses if at all possible. If it’s a timed thing, then yes, a BindableEvent is an option. Honestly, if the starter menu is a one time thing I would either tie in to the player loading system or something else rather than bind it
ill look more into bindable events and functions but would i use a bunch of bindable events since i want it in order into something like the quest system i mentioned with many scripts?
Depends. Up to you to decide how you want to structure the system