thank you, but do you know why this is not working?
local RoundGui = game.StarterGui.RoundGui
local IntermissionTime = 20
while wait(1) do
RoundGui.Frame.TextLabel.Text = "Intermission: "..IntermissionTime.." Seconds"
IntermissionTime = IntermissionTime - 1
end
If youâre doing that, then you have two ways to accomplish that: either have it in ServerStorage and clone it to each player as they join (more difficult), or have it in StarterGui, and simply update the intermission time when a player joins. This will require a remote event, as Jech pointed out, to properly synchronize the time.
The issue in your original script is that youâre referencing StarterGui, not PlayerGui as Lightning pointed out. When a player joins the game, the contents of StarterGui are copied into PlayerGui, a sort of âfolderâ that each player will have.
If your script is inside the RoundGui, you could reference it with script.Parent or something similar.
If that script is in the Server Script Service then to change the gui for all of the players do:
You can create a String Value for the Gui, and change the value from the Server Script Service
and in the gui, create a local script, that changes the guiâs text to the value, every time the value changes.
like:
local value = game:GetService("ReplicatedStorage").StringValue
script.Parent.Text = value.Value
value:GetPropertyChangedSignal("Value"):Connect(function()
script.Parent.Text = value.Value
end)
In this case, the local script is inside the Text Label
local RoundGui = game.StarterGui.RoundGui
local IntermissionTime = script.IntermissionTime
for i=20,1,-1 do
RoundGui.Frame.TextLabel.Text = "Intermission: "..IntermissionTime - 1 .." Seconds"
wait(1)
end
Create a string value in the Replicated storage, change the valueâs value to the intermissionâs text, and get the value from the playerâs gui. like I showed in the post before
I have done things like that many times, it worked for me
StarterGui is nothing other than a folder that houses what gets copied to playersâ guis.
The contents are cloned and parented to somePlayer.PlayerGui
It is also highly inadvisable to be manipulating GUIs on the serverâs side (for a multitude of reasons). Find some way to send the time values from the server to the client, whether it be via remote events, values, or whatever. Then, on the client, change the text to match. What I usually do is send some sort of timestamp to clients and have them make their own countdown based on this. But, you can make it very simple with just an IntValue or StringValue and use val.Changed for your update function.
Interesting. I havenât heard of many reasons why you wouldnât want to do that, and even in my own games Iâve had times where I found it easier to simply clone the UI to the client after populating it on the server side. Why would it not be optimal?
Hereâs an example:
in the Server Script Service:
local RoundGui = game:GetService("ReplicatedStorage").StringValue --Whatever the name is
local IntermissionTime = 20
while wait(1) do
RoundGui.Value = "Intermission: "..IntermissionTime.." Seconds"
IntermissionTime = IntermissionTime - 1
end
and in the text label itself:
local value = game:GetService("ReplicatedStorage").StringValue --Whatever the name is
script.Parent.Text = value.Value
value:GetPropertyChangedSignal("Value"):Connect(function()
script.Parent.Text = value.Value
end)
There are over 20 reasons but I will be general and explain the most important ones:
The server has extra load now that it has to be constantly manipulating peopleâs GUIs for no reason, when they could just be doing it themselves instead, especially if it is busy trying to make 200 peopleâs coins spin or something equally as useless
GUIs are usually almost always only client-sided, meaning the server wouldnât and shouldnât be able to access them directly or even be able to interact with them
The clientâs GUI is on their computer, so if theyâre the one manipulating it, it will always look far cleaner than if the server were to try and animate it themselves and replicate it over the network
The server is completely incapable of listening to any GUI events, including those in SurfaceGuis and BillboardGuis, as GUI interaction is handled only client-side
It is really bad practice. You want all visuals to be handled client-side. And, if using OOP, you will not be able to share your custom classes for your GUI across remote events and such, thus, you should use the server to initiate, verify, confirm, and communicate interactions and conversations. The server doesnât need to care (at all) about whatâs happening in the GUI, as long as the correct information is being relayed.
Communication should be achieved by having conversations between the client and server, sending only what is necessary, and not by manipulating the clientâs screen directly.
âŚ
Fair enough. I guess offsetting server load is better in most cases for all players.
Going back on topic, @SadWowow21, if youâre interested in learning more about how a server-wide countdown can be handled, you should check out this article right here. It helped me quite a bit in figuring out how to build the system.
@LightningLion58 âs example is the way I would do it. Having the server set the time will keep the timer the same for all clients otherwise individual clients will become out of step.