Why doesn't my text change?

It’s either the script or the GUI

I made a text label inside a ScreenGUI and made a script inside the text label.

I made the script change the text which worked, but you need to reset every time you want to see it update.
How do I make it update every 1 second?

can you provide context(The script, or the GUI, or a download.)

1 Like

Well you can put the code into a while loop.

while wait(1) do
	-- code here
end
1 Like

I did

local text = script.Parent

local value = game.Workspace.Value

while true do
value = 300
text.Text = value.Value
wait(1)
value.Value = value.Value - 1
end

I need it to update the text every second*

i did try it unless I did something wrong

are you getting an error of sorts

1 Like

You’re setting the value back to 300 every time the loop is called

Try this

local text = script.Parent

local value = game.Workspace.Value
value.Value = 300

while true do
    text.Text = value.Value
    wait(1)
    value.Value = value.Value - 1
end
1 Like

I’m not, it just updates the text after resetting my character

Try

local value = workspace:WaitForChild("Value")

value.Value = 300

while wait(1) do

script.Parent.Text = tostring(value.Value)

value.Value += -1

end
1 Like

Yea, thats actually what I’m trying to do. Making a sort of minigame that restarts.

Does that work with words too?

Okay, I guess I can change my type of value to words and it work with words.

Oh your trying to make a timer?

1 Like

You don’t need to reference it inside the TextLabel as that’ll change for every player that joins the game, the way you have it now is that if this is a ServerScript, the value will change in different intevals depending on how much players there are

You could just put the value inside ReplicatedStorage, leave the changing script inside ServerScriptService, and put a LocalScript in the TextLabel to detect when the Value gets changed:

--Server Script
local Value = game.ReplicatedStorage:WaitForChild("Value")

Value.Value = 300

while wait(1) do
    script.Parent.Text = tostring(Value.Value)
    Value.Value -= 1
end
--LocalScript inside the TextLabel
local TextLabel = script.Parent
local Value = game.ReplicatedStorage:WaitForChild("Value")

Value.Changed:Connect(function(NewValue)
    TextLabel.Text = tostring(NewValue)
end)
2 Likes

That will work too. I honestly didn’t think of that