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

Why doesn't the text change when the intvalue changes?

The problem is that the text does not change when the value changes. It would be much appreciated if someone could help.

local wood = sp:WaitForChild("WoodValue")
local woodvalue = wood:WaitForChild("Value")

if wood and woodvalue then
	wood.Text = woodvalue.Value
	while true do
		woodvalue.Value = woodvalue.Value + 1
		wait(0.1)
	end
end

1 answer

✓ Accepted answer

The problem is that you only change the value once. To fix this, move line 5 to be inside the loop:

local wood = sp:WaitForChild("WoodValue")
local woodvalue = wood:WaitForChild("Value")

if wood and woodvalue then
    while true do
        woodvalue.Value = woodvalue.Value + 1
	wood.Text = woodvalue.Value
        wait(0.1)
    end
end

However, if this not the only place woodvalue gets updated, it would be better to use the Changed event, like this:

local wood = sp:WaitForChild("WoodValue")
local woodvalue = wood:WaitForChild("Value")

if wood and woodvalue then
	woodvalue.Changed:connect(function()
		wood.Text = woodvalue.Value
	end)
	while true do
		woodvalue.Value = woodvalue.Value + 1
		wait(0.1)
	end
end

1 comment

0

Thanks, it worked.

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