Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I update the text of the TextBox?

Asked by
painzx3 43
9 years ago

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

Log in to vote
0
Answered by
dyler3 1510 Moderation Voter
9 years ago

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

0
Thanks for the suggestion but could you please define or specify "Property" because the same issue occurs. painzx3 43 — 9y
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. dyler3 1510 — 9y
Ad

Answer this question