ScreenGUI Not Working

Hello,

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!

Before player died:
image

After player has died once:
image

My code that sets up the GUI:

2 Likes

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)
1 Like

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?

On Server:

On Client:

There’s something wrong with that first picture…

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.

Yes, I double checked to make sure that it is indeed the second.

I will go back and try to add a remote event that updates the serve side of things. Thank you so much for your insight!

1 Like