Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
lucas4114 607 Moderation Voter
9 years ago

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

Log in to vote
2
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

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!

0
Works.. :D lucas4114 607 — 9y
Ad
Log in to vote
1
Answered by 9 years ago

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)

Answer this question