Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a GUI's text the same for everyone?

SO... I have a GUI in starter GUIs, it's a game timer for the time left in rounds for my game, so theres a script in it that changes it.. BUT, the GUI isn't the same for everyone. D: If a player dies or a player joins at a different time the GUI goes on but shows it's own time.. I want the GUIs to show the same text...

2 answers

✓ Accepted answer

As a majority of game developers do, I would set values in Workspace, that represent the time. After those values are created, if you haven't already, create a Main Game Script in Workspace, that manages the time, rounds, etc. The script should keep updating the value in Workspace with the current time. Now, once that is all set up, time to make it update in all players. In the Frame of the GUI that should be located in StarterGui (Or wherever you store it), create a script within the TextLabel. The script should have a while loop, that constantly updates the text with the time.

Example:

while wait() do
	script.Parent.Text = game.Workspace.Timer.Value
end

If you want to have it in minutes and seconds, that's something a bit different. The value will most likely be in seconds, so to put that into minutes, you'd need to divide it by 60. I'm not at my personal laptop right now, which has Studio installed, but you can grab the timer portion from one of the ROBLOX Preset games. To do so, in Studio, create a new game, and I believe the game itself is called "Capture the Flag" or some sort. After you go into Edit mode, locate the script that handles the time, and copy the portion that converts it into minutes and seconds.

Hope I helped!

1 comment

0

Works.. :D

I would not use

while wait() do
    script.Parent.Text = game.Workspace.Timer.Value
end

instead try:


game.Workspace.Timer.Value.Changed:connect(function()
	script.Parent.Text = game.Workspace.Timer.Value
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.