So in Workspace, I have a folder named meep that contains an int value named Why. I also have a script that successfully changes the Why int value into 0 after 3 seconds. Thus, all the things that I'm printing are being printed in the output. However, the GUI does not show up even though the GUI's visible status is true. (It also becomes true when I tested it ). Also, I found out that the GUI does work correctly after resetting the character.
In Conclusion: - int value gets changed -function gets activated -Gui becomes visible but the Gui does not appear on the screen - Gui, however, does appear on the screen on the screen after resetting the character.
game.Workspace.meep.Why.Changed:Connect(function() wait(1) print("Hello") if game.Workspace.meep.Why.Value == 0 then print("H3llo") game.StarterGui.ScreenGui.Dave.Visible = true else game.StarterGui.ScreenGui.Dave.Visible = true end end)
Might be because the StarterGui is not where your gui is. Once the game starts everything in the startergui is cloned to the players PlayerGui. If you want to make something visible on your screen, you need to do it in your PlayerGui.
localplayer = game.Players.LocalPlayer game.Workspace.meep.Why.Changed:Connect(function() wait(1) print("Hello") if game.Workspace.meep.Why.Value == 0 then print("H3llo") localplayer.PlayerGui.ScreenGui.Dave.Visible = true else localplayer.PlayerGui.ScreenGui.Dave.Visible = true end end)
Basically you do the same thing you already did but change "game.StarterGui" to "<localplayer>.PlayerGui". That way you are editing the gui that your player sees.
Im not very good at explaining this, sorry if you dont understand.
The reason why your GUI only appears after resetting the character is that you're editing the StarterGui instead of the PlayerGui. StarterGui is essentially a container for all your GuiObjects that you want cloned into the player's PlayerGui each time they respawn. PlayerGui is the same thing, except it contains the GuiObject's that the player is CURRENTLY looking at. So if you wanted to make a change while the player is playing a game you should most of the time change the PlayerGui.
In order to access the PlayerGui, use a LocalScript and the following code:
local plr = game.Players.LocalPlayer local plrGui = plr:WaitForChild("PlayerGui") --It's recommended to use WaitForChild because sometimes the player is added into the game after LocalScripts so it's just a safety precaution local screenGui = plrGui:WaitForChild("ScreenGui") workspace.meep.Why.Changed:Connect(function() wait(1) print("Hello") if workspace.meep.Why.Value == 0 then print("H3llo") screenGui.Dave.Visible = true else screenGui.Dave.Visible = true end end)
If this answered your question, please mark it as the answer, and if you have any other questions please comment below!