What I want is to have the server effect everyone’s GUI equally, and basically have the GUI constant for everyone as well.
For example, should a timer count down, the timer will count down equally for everyone and the same time will be displayed.
Should there be 2 players, and a player leaves and joins back, I want the timer to pick up not where it left off, but where it is for every other player as well.
Use a server script in server script service and work with StarterGui, not playergui.
wait a server script can reference starter gui?
and that will work for the whole server? i thought altering starter gui did nothing?
There is many ways to do this. Probably the easiest and most common method is to store a NumberValue | Roblox Creator Documentation in ReplicatedStorage | Roblox Creator Documentation in order for the server and client to have access. Then on the client connect a .Changed event.
Your server script would look something like :
local NumberValue = ReplicatedStorage:WaitForChild("NumberValue")
NumberValue.Value = 10 -- count down from 10
while NumberValue.Value > 0 do
NumberValue.Value -= 1
task.wait(1)
end
Then your client script :
local NumberValue = ReplicatedStorage:WaitForChild("NumberValue")
textLabel.Text = NumberValue.Value -- set the current value
NumberValue.Changed:Connect(function(newValue) -- when the value changes
textLabel.Text = newValue
end)
the timer was an example
what if i want to make things appear, tween things, have images, have text, and all that
Okay, so a NORMAL script can reference the WHOLE server. (LocalScripts are client only.) ALSO, do NOT use PlayerGui. (That only works for 1 player.) Instead, to make server-sided changes to a GUI, use StarterGui.
In this case a RemoteEvent | Roblox Creator Documentation would be your best bet. You can fire events from the server and listen to them on the client in order to invoke something
Similarly to the NumberValue this goes in ReplicatedStorage.
Server :
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
RemoteEvent:FireAllClients("Tween Stuff")
Client :
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
RemoteEvent.OnClientEvent:Connect(function(message)
if message == "Tween Stuff" then
-- do your tweening
end
end)
You can have different RemoteEvents for different actions.
yes i know the difference between a local script and a server script its just that i thought editing starter gui didnt do anything lol
so just to be sure
serverscript + startergui = gui change for all players
Yes, correct. This text will be blurred
So just a question about this
How come modifying starter gui withscripts can affect the players ui throughout the game, but a local script cant? Why do we have to use playergui? If the server can do it, couldnt the client do it, but, you know, only client sided?
So PlayerGui is basically StarterGui, but ONLY for the player. StaterGui is a sever-wide GUI. A LocalScript is only for the client also, so it will only really change the GUI for the client running the code. IF you are making a shop open and close, you should change that in the PlayerGui though, to cause less problems that could occur.
why would roblox create a whole new thing (playergui) for altering client gui and not just let the client locally change startergui
Because PlayerGui is only changeable to the Player which the PlayerGui is parented to. If you changed something in StarterGui, it could show it on another clients screen instead of the player using the script or button.
Also, I’m at school, so sorry for late responses.
youre good lol
thanks for the help, ill go use it now
Yep, also if I did help you fix this, mark me as solution, so people are aware this is solved!
Stater GUI, like starter character, stater player, and backpack, are all instantiating folders.
Whatever is in these folders when a Player is added or their character is loaded copies from these folders into their respective places
Stater Gui into Player gui
Backpack into Backpack
Stater character into character
Etc
A server editing the objects within Starter GUI will show, but only when you Reload the player’s character.
Unless something has changed in the last 5 years, Roblox has always worked this way.
Yes, but they were asking how PlayerGui works.
oh shoot
well im trying to have it constantly update server-wide without players being reset, how would i accomplish that?
That’s fair, the way you phrased your responses seemed like you could edit everyone’s active Guis from the server, which you cannot.