I'm trying to make a text that's on a surface GUI change to whatever the integer value is, but it doesn't change at all.
local text = script.Parent.Text
local val = script.Parent.Value.Value
text = ""..val
Thanks if you can help.
I'm trying to make a text that's on a surface GUI change to whatever the integer value is, but it doesn't change at all.
local text = script.Parent.Text
local val = script.Parent.Value.Value
text = ""..val
Thanks if you can help.
You need to add an event so it fires and runs the code.
local text = script.Parent.Text
local val = script.Parent.Value
val.Changed:connect(function() --Fires when the value changes
text = val.Value --Sets the text to the value
end)
This is because you are setting your variables to the VALUE of the property, not the property itself.
The variable is set to the value of the property at the time, so instead of adding a .Value or a .Text remove it.
Do this instead:
local text = script.Parent
local val = script.Parent.Value
text.Text = tostring(val) -- we will preset the value.
val.Changed:Connect(function() -- Put this in a changed event so it runs when the value changes.
text.Text = tostring(val)
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
let me get this straight, the script is in the textbox and the NumberValue/Intvalue is parented by the script too? becuase if script.Parent.Text is the textbox then you forgot to add another .Text or else you are trying to set the instance to a number rather setting the text property to the number