GUI Changing Script not working!

1. I was trying out a script for switching GUI within time… But it wasn’t working, I looked at the Output but there were no errors of what so ever. I’m in need of help!

2. The problem i’m having is the Code I have written isn’t working properly, it’ll glitch or it won’t work at all, I’ve put the script in everything without it working.

This is my code:

Out = game.StarterGui.Exit.Leave
P1 = game.StarterGui.Song.Paragraph1
P2 = game.StarterGui.Song.Paragraph2
P3 = game.StarterGui.Song.Paragraph3
P4 = game.StarterGui.Song.Paragraph4
P5 = game.StarterGui.Song.Paragraph5
P6 = game.StarterGui.Song.Paragraph6
P7 = game.StarterGui.Song.Paragraph7
P8 = game.StarterGui.Song.Paragraph8
P9 = game.StarterGui.Song.Paragraph9
P10 = game.StarterGui.Song.Paragraph10
P11 = game.StarterGui.Song.Paragraph11
P12 = game.StarterGui.Song.Paragraph12
P13 = game.StarterGui.Song.Paragraph13
P14 = game.StarterGui.Song.Paragraph14

wait(4)
game.StarterGui.Song.Paragraph1.Enabled = true
wait(15)
game.StarterGui.Song.Paragraph1.Enabled = false
wait(1)
game.StarterGui.Song.Paragraph2.Enabled = true
wait(15)
game.StarterGui.Song.Paragraph2.Enabled = false
wait(2)
game.StarterGui.Song.Paragraph3.Enabled = true
wait(15)
game.StarterGui.Song.Paragraph3.Enabled = false
wait(2)
game.StarterGui.Song.Paragraph4.Enabled = true
wait(15)
game.StarterGui.Song.Paragraph4.Enabled = false
wait(2)
game.StarterGui.Song.Paragraph5.Enabled = true
wait(15)
game.StarterGui.Song.Paragraph5.Enabled = false
wait(2)
game.StarterGui.Song.Paragraph6.Enabled = true
wait(15)
game.StarterGui.Song.Paragraph6.Enabled = false
wait(2)
game.StarterGui.Song.Paragraph7.Enabled = true
wait(15)
game.StarterGui.Song.Paragraph7.Enabled = false
wait(2)
game.StarterGui.Song.Paragraph8.Enabled = true
wait(15)
game.StarterGui.Song.Paragraph8.Enabled = false
wait(2)
game.StarterGui.Song.Paragraph9.Enabled = true
wait(15)
game.StarterGui.Song.Paragraph9.Enabled = false
wait(2)
game.StarterGui.Song.Paragraph10.Enabled = true
wait(15)
game.StarterGui.Song.Paragraph10.Enabled = false
wait(2)
game.StarterGui.Song.Paragraph11.Enabled = true
wait(15)
game.StarterGui.Song.Paragraph11.Enabled = false
wait(2)
game.StarterGui.Song.Paragraph12.Enabled = true
wait(15)
game.StarterGui.Song.Paragraph12.Enabled = false
wait(2)
game.StarterGui.Song.Paragraph13.Enabled = true
wait(15)
game.StarterGui.Song.Paragraph13.Enabled = false
wait(2)
game.StarterGui.Song.Paragraph14.Enabled = true
wait(15)
game.StarterGui.Song.Paragraph14.Enabled = false
wait(2)
game.StarterGui.Exit.Leave.Enabled = true

wait(25)

game.Workspace.Save.Looped = true
game.Workspace.Save.Playing = true

I was sure that the script would work correctly, but it didn’t.

Whenever a player joins the game, the contents of StarterGui are essentially copied into the PlayerGui folder under their player instance. With this in mind, we can also come to a conclusion that changes made to StarterGui won’t show for other clients unless they either join/rejoin the game, or they reset their character (And ResetOnRespawn on the ScreenGui is enabled). To get around this, you could loop through all the clients and change their PlayerGuis, or you could use RemoteEvents to signal to the clients to update their respective GUIs.

For example:

for i,player in pairs(game.Players:GetPlayers()) do
     const PlayerGui = player:WaitForChild("PlayerGui")
     -- Make change to their PlayerGUI here
end```
2 Likes

well it would probably be more effective to loop through the paragraphs enabling them in the loop. but i still have yet to see why this would glitch if its only going to one player and it being on starter gui which means anyone ingame wont be updated

Would it still work if the game would be for one player?

I’m sorry… I don’t seem to be catching on to this?

Well your main problem is using starter gui to change something that should be changed in playergui if you fix that I don’t see why it wouldn’t work for one player

The StarterGui service and the Local Player GUI are 2 different things if that makes sense

Let’s say if I were to put this line of code inside a Server Script:

game.StarterGui.Exit.Leave

That’ll change only Server-Sided (Or what the Server is currently seeing right now), but it won’t Client-Sided (Aka your Client/ROBLOX Player, or what GUI’s you see whenever you play a game)
Every client has a different StarterGUI on how it functions, so it can’t work via using StarterGui, so how could you make it work?

We use something called: RemoteEvents, and they’re special things to say the very least. What do they do? Well, they fire certain data from the Server/Client or Client/Server!

--This is a Server Script:
local Event = game.ReplicatedStorage:WaitForChild("Event")
Event:FireAllClients() 

We’re using the function FireAllClients, as that will Fire an event to all current Clients (Or Players) that are in the game

--This is a Local Script
local Event = game.ReplicatedStorage:WaitForChild("Event")
local Player = game.Players.LocalPlayer
Event.OnClientEvent:Connect(function()
    --Insert your line of code here, but replace StarterGui with Player.PlayerGui
end)

If you’re not familiar what a LocalScript is, it’s basically a Script but that’s only visible to the current Client (Or current Player who’s viewing it)