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

why wont my textlabel change to the value of something?

so i want to make a timer but i am not sure why the value isn't changing or why the text isn't showing as the value. this is the script i have inside of the Textlabel

local Timer = game.ReplicatedStorage.Timer

script.Parent.TextLabel.Text = (Timer.Value)

while true do
	game.ReplicatedStorage.Timer.Value = -1
	wait(1)
end

1 comment

0

I made edits to my answer so it could work a little better.

1 answer

✓ Accepted answer

The reason why this doesn't work is that the text isn't changing every time the value is changed. It was a small error but can be simply fixed by doing:

local Timer = game.ReplicatedStorage.Timer

script.Parent.TextLabel.Text = (Timer.Value)

while wait(1) do
	game.ReplicatedStorage.Timer.Value = game.ReplicatedStorage.Timer.Value -1
	script.Parent.TextLabel.Text = (Timer.Value)
end

If you wanted the timer to stop at zero, you could do something like this:

local Timer = game.ReplicatedStorage.Timer

script.Parent.TextLabel.Text = (Timer.Value)

repeat wait(1)
	game.ReplicatedStorage.Timer.Value = game.ReplicatedStorage.Timer.Value -1
	script.Parent.TextLabel.Text = (Timer.Value)
until
game.ReplicatedStorage.Timer.Value == 0

1 comment

0

It's easier to use Instance:GetPropertyChangedSignal("Value"):Connect(callback)

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