Quite an easy script is failing to work (Value not updating in Text)

This is a local script placed under a TextLabel, which is intended to update Text with a Changed number Value, but it fails to do so while the print function does actually print out changed numbers. How do I update the Text through this script?

P.S. value is NumberValue

local value = script.Parent.Value

function updatedValue()
	script.Parent.Text = "Difficult Buttons Clicked:"..value.Value.."/10"
end

value.Changed:Connect(print, updatedValue)
value.Value = 0

you have defined this wront, rewrite it as local value = script.Parent and your script should work fine

script.Parent is the TextLabel itself, are you sure about that working because what I meant about the value is NumberValue placed under TextLabel

if that’s that case, that’s not causing the issue

try debugging using print statements inside updatedValue function

1 Like

strangely, print placed in updatedValue function only prints out Value either when putting value.Value = 0 before or after whole function of updatedValue

so if the print inside updateValue prints, the text also should change, is it changing ?

Hey try this i think this will work:

local value = script.Parent:WaitForChild(“Value”)

function updatedValue()
script.Parent.Text = “Difficult Buttons Clicked:”…value.Value…“/10”
end

value.Changed:Connect(print, updatedValue)
value.Value = 0

somehow the print value placed inside updatedValue made the script work with value.Value = 0 being placed above the function, well i have to thank you for your debug suggestion which made it work

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.