I have a script that changes the text of a GUI every second, as a countdown timer.
intermissionTime = 5*60 while true do local intermission = game.StarterGui.ScreenGui.Intermission local timeLeftIntermission = intermission.IntermissionTime intermission.Visible = true timeLeftIntermission.Text = intermissionTime intermissionTime = intermissionTime - 1 print(timeLeftIntermission.Text) wait(1) end
When I run the script, the GUI changes as it should...counting down every second from 300. But when I Play the game, it doesn't, but simply stays at 300. I added a print
line to check what was going wrong, and it says that it is changing, but it isn't. This is not the first time this has happened. Why doesn't this work?
You could try something like this
time = 300 -- You can change this for i=time, 0, -1 do wait(1) local intermission = game.StarterGui.ScreenGui.Intermission local timeLeftIntermission = intermission.IntermissionTime intermission.Visible = true timeLeftIntermission.Text = "Time Left "..i end
This is basically your script, but runs on a for loop which stops when it reaches 0, you can edit the time at the top :)
First, you have to link the text to a string value. What you want to do is put a string value in Replicated Storage. Next, once you have the string value, you want to connect the string with the text label. You have to enter a local script into the text label.
--The Text Label local replicatedstorage = game:GetService('ReplicatedStorage') -- You are accessing the Replicated Storage local status = replicatedstorage.Status -- This is what I'm naming it. You don't have to name it status script.Parent.Text = status.Value status.Changed:connect(function() script.Parent.Text = status.Value end)
The next step is to put a script into the Service Script Storage. This is where you will begin the countdown.
Once you have it, you have to type this:
--Main Script local replicatedstorage = game:GetService('ReplicatedStorage') -- Once again, you need to obtain Replicated Storage local status = replicatedstorage.Status for i = 300, 0, -1 do -- Subtracting 1 from 300 each second until it reaches 0 status.Value = "Intermission: "..i -- Remember, i is (300, 0, -1) wait(1) -- Waits one seconds before subtracting 1
Hope this helps!!!
You shuld try something like this:
for i = 300, -1 do
wait(1) Intermission.Text = "time left" .. i end