I updated the content of a screenGUI using a script (see the big white box on top of screen in the pictures). But the updated content won’t show in the game until the player has died once. Can someone help me figure out what’s going on? Thanks!
StarterGui is only where GUIs get put to get given to players when they spawn. The actual GUIs players are seeing are inside each of their player’s PlayerGui folders. (e.g. location of the GUI for me would be game.Players.EmeraldSlash.PlayerGui.GUI). The server cannot access the contents of PlayerGui, though.
Instead, to update each player’s PlayerGui, you will need to have a LocalScript running inside the GUI that listens for a RemoteEvent telling it what to display, e.g:
-- LocalScript inside your ScreenGui
local text1 = script.Parent.TextLabel
remoteEvent.OnClientEvent:Connect(function(timer)
if timer >= 10 then
-- ...
end
end)
And on the server:
remoteEvent.OnServerEvent:Connect(function(player, timer)
-- Tell all the clients to update their timer
remoteEvent:FireAllClients(timer)
end)
Thank you so much for the reply! I will try that out.
A different but related question: when I am testing my game, when looking from the service side, the gun seems to be floating behind the player. But when I switch to the client’s perspective, the gun is in the player’s hands…
Do you think this has anything to do with the player’s views being different from the client’s view?
Since I can’t see yet, I can’t help very much, but what do you mean by floating behind the player? Does it move from its original position at all (e.g. attached to the player but always a few studs behind or something), or is it just sitting in the same spot?
Changes made by the client don’t get replicated to the server except in special cases, so it’s probably that if you chose the second answer.