I've been experiencing an issue with my game's GUIs. The GUIs do not replicate themselves to the player's PlayerGui, and the properties change in StarterGui instead of PlayerGui. I am using a normal script to control each GUI.
The Output gave me no errors.
01 | Mainbar = game.StarterGui.Mainbar |
02 | --------------- |
03 | MainbarFrame = Mainbar.MainbarFrame |
04 | --------------- |
05 | MainbarText = MainbarFrame.MainbarText |
06 | --------------- |
07 | LobbyMusic = game.workspace.LobbyMusic |
08 |
09 | --------------------------------------- |
10 | --||MAIN FUNCTIONS||-- |
11 | --------------------------------------- |
12 | while true do wait( 1 ) |
13 |
14 | wait( 2 ) |
15 |
You have two errors in your script. One is that you forgot an end, and two is you didn't define the playergui. You can't just change the text in startergui you have to change the text in the playergui. So you have to define all the players in the game than get all of their playerguis. Like this:
1 | for _, player in ipairs (game.Players:GetChildren()) do -- this gets all the players in the game and defines all of them as player! |
2 | --code |
3 | end |
This should be your whole script:
01 | Mainbar = game.StarterGui.Mainbar |
02 | --------------- |
03 | MainbarFrame = Mainbar.MainbarFrame |
04 | --------------- |
05 | MainbarText = MainbarFrame.MainbarText |
06 | --------------- |
07 | LobbyMusic = game.workspace.LobbyMusic |
08 |
09 | --------------------------------------- |
10 | --||MAIN FUNCTIONS||-- |
11 | --------------------------------------- |
12 | Mainbar = game.StarterGui.Mainbar |
13 | --------------- |
14 | MainbarFrame = Mainbar.MainbarFrame |
15 | --------------- |
The StarterGui does not actively update GUIs in other players' PlayerGui. All it does is clone its contents into their PlayerGui each time they spawn. If you want the PlayerGuis to be updated, you'll have to loop through each player's PlayerGui and modify them manually.
If not using FilteringEnabled, you can directly read and and change the values of GUIs in the PlayerGui, and can use that same script you're using now if you replace each line that changes the StarterGui to a loop that changes the GUI in every player's PlayerGui.
If using FilteringEnabled, a regular script won't be able to see or modify what's in a player's PlayerGui and you'll have to use RemoteEvents/RemoteFunctions to communicate these values to the player and have them update their own GUI with a local script.