Setting Text to a Number Value

Can someone explain to me why this code is not working?

local value = script.Parent.Parent.Blocks.Value

script.Parent.Text = value

value.Changed:Connect(function()
	script.Parent.Text = value
end)

I want to make it so that the text, is continuously changed to the integer value. When I do it, I only get the first integer number. But, after the value gets changed it does not update the text.

It is because the value of the variable is not updated, do this:

local value = script.Parent.Parent.Blocks

script.Parent.Text = value.Value

value.Changed:Connect(function()
	script.Parent.Text = value.Value
end)
1 Like

Still didn’t work, does it have to be a local script or something?

I’m currently at my phone because our class software wouldn’t let me out. So, put the local variable inside the value.Changed function instead.

Do you see any errors in the output? Is the code in a local script or a server script and where is it placed?

Yeah,

Here is where it is placed:

That didn’t work, either. (30 letters)

local devilArmor = script.Parent
local frame = devilArmor.Parent
local blocks = frame:WaitForChild("Blocks")

devilArmor.Text = blocks.Value

blocks.Changed:Connect(function(newValue)
	devilArmor.Text = newValue
end)

Make the script a local one.

Are you using an ObjectValue? (30 limit aaaa)

The error could be because the instance class is an ObjectValue and the value is an instance, try using value.Value.Name instead

Thank you! It worked! (30 letters)