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

How do I update the text of the TextBox?

I have a textbox in a surfaceGui and I'm trying to make it so that if the value of a NumberValue within the model goes up the text changes accordingly. The code I have works but if the value increases/decreases it will remain at 500. No errors.

if script.Parent.Value == 500 then
	script.Parent.Parent.SurfaceGui.Frame.TextBox.Text = script.Parent.Value .. " , 7.62x51mm BOX MAGAZINES"
end

1 answer

✓ Accepted answer

The code you had only changed the Value if the NumberValue was at 500. This should fix it:

script.Parent.Changed:connect(function(Property) --Fires whenever the value changes
	    script.Parent.Parent.SurfaceGui.Frame.TextBox.Text = script.Parent.Value .. " , 7.62x51mm BOX MAGAZINES"
end)

The code should work now. I switched the "if" statement with a function so that it runs every time the value is changed. Anyways, if you have any further questions or problems, please leave a comment below. Hope I helped :P

2 comments

0

Thanks for the suggestion but could you please define or specify "Property" because the same issue occurs.

0

Ah, sorry about that. I updated my answer, and I believe it should work now. No need for the Property, because it's a NumberValue, and Value is the only thing that will be changing anyways.

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