You don’t need a while loop, that’s inefficient
Yes, but while loop needs a small wait(), I think it’s much better to change it every time the value changes. While loop is also much less efficient, functions are better because they don’t run so many times as the while loop. Also, loops can’t run for an infinite amount of times. I once created a script and forgot to implement debounce, and my computer rebooted itself, it was too much for it. I was shocked.
Is this solved? If not I can write a solution.
local RoundGui = game.PlayerGui.RoundGui
local IntermissionTime = 20
for i = IntermissionTime,0,-1 do
RoundGui.Frame.TextLabel.Text = "Intermission ".. i .." Seconds"
wait(1)
end
Boom. If it wasn’t solved I think this’ll work. I tested it out.
Does it actually work for you? You refer here to the StarterGui, not the PlayerGui, does it actually change the GUI?
That’s how I did it but I used his locals. I think it’d be PlayerGui then.
We will see what works for him later I guess, I posted a solution too, but he did not respond yet.
to add onto what the others are saying, another reason why the script is not working (other than improper string concatenation) is that you’re changing the GUI on StarterGui and not PlayerGui.
StarterGui is a service used to clone anything in it into the Player’s PlayerGui when they spawn or join the game, and because of that, it doesn’t update unless you rejoin or die.
To counteract that, we’ll use StringValues, as they can easily be manipulated by the Server and can replicate to the client with events.
local TextLabel = script.Parent --The TextLabel
local Status = game:GetService("ReplicatedStorage"):WaitForChild("Status") --The StringValue
Status.Changed:Connect(function() --An event that fires every time a property of the StringValue changed, in this case the Value
TextLabel.Text = Status.Value --Change properties accordingly
end)
The code is relatively simple, and to comment on the reason why putting it in ReplicatedStorage is really important is because that can be accessed by the client/server. And for the server script, we’ll just use a simple script in ServerScriptService to change the Status.
local Status = game:GetService("ReplicatedStorage"):WaitForChild("Status") --The StringValue
for i = 30,0,-1 do --A loop that starts and repeats 30 times, with i being 30 at first and decreasing by -1 every time the loop completes.
Status.Value = "Intermission: "..i.." Seconds" --We change the StringValue with the "i" variable and also with additional text
end
This unfortunately won’t work, since PlayerGui isn’t exactly a service but more as a folder within the Player object in the PlayersService that contains GUIs that are replicated from the StarterGui service.
How it works is that every time the player respawns or joins the game, all the contents within StarterGui is cloned immediately into the PlayerGui.
local Player = game:GetService("Players").LocalPlayer
local RoundGUI = Player:WaitForChild("PlayerGui"):WaitForChild("RoundGui")
Another thing is that we don’t need to use the PlayerGui to even access the RoundGui, alternatively and a much more efficient solution would be creating a local script within the RoundGui that changes the Text, though that only applies to the client (unless we use RemoteEvents/StringValues to change the text via Server)
That is exactly what I said, changing values is easier than firing events in my opinion.
Hey, have you been able to solve your script?
sorry i didn’t see your reply lol
this doesnt seem to be fixed, so ill do my best again
put this in a local script, inside the gui object
local RoundGui = script.Parent.RoundGui
local IntermissionTime = 20
while wait(1) do
RoundGui.Frame.TextLabel.Text = "Intermission: "..IntermissionTime.." Seconds"
IntermissionTime = IntermissionTime - 1
end
as for how it’ll work with events, just send the value to the clients every 1,2,3,4,5 whatever seconds (if you use more than 1 second, just make it count down client-side
no, I have stopped working on the intermission gui for now, and more on the game itself
nvm, I just forgot to make a frame xD thank you for the help!