I add 1 value to an IntValue, and so the IntValue's value is supposed to update onto a TextLabel, how am I supposed to do that?
To accomplish this, you need to use the Changed
event.
So let's say I have a script that increases the IntValue by one every 3 seconds:
while wait(3) do local int = script.Parent.IntValue int.Value = int.Value + 1 end
And I have a script that checks if the IntValue
has changed, and if so, updates my TextLabel
:
script.Parent.IntValue.Changed:Connect(function() local textLabel = script.Parent.TextLabel textLabel.Text = script.Parent.IntValue.Value end)
For more information, consult the Roblox Wiki, but for now, please accept my answer if this helped! Hierarchy here.
Hey, Araknala
If you want to update a TextLabel with an IntValue, in the script make sure to write :
.IntValue.Value
If you put .Value, if the IntValue is 2 you can update it which will also change the TextLabel.
Hope this helps!
~oSy
In order to update the text displayed on a TextLabel, use the Text
property:
http://wiki.roblox.com/index.php?title=API:Class/TextLabel/Text
You can update it by setting it with =
, just like a variable.
textLabel.Text = intValue.Value
Hello there! You must convert the IntValue to a StringValue
This is what you are looking for:
http://wiki.roblox.com/index.php?title=Global_namespace/Basic_functions&redirect=no#tostring
Example:
Let's suppose you have an IntValue named CarWheels, which's value is 4 and it's parent is the same as your script.
You also have a textlabel that must indicate the amount of wheels, with the same parent.
script.Parent.TextLabel.Text = tostring(script.Parent.CarWheels.Value)
If what you're saying is you want to update a value which will then change the value of a textlabel then surely you'd do:
local int = intvaluelocation local textlabel = textlabellocation int.Changed:connect(function() textlabel.Text = int.Value end)
Also, don't forget to resize and choose the correct face on your SurfaceGui!
You need to use the .Changed event. When the IntValue's value changes, the .Changed event will fire and then you can change the TextLabel's text.
IntValue.Changed:Connect(function(Change) if Change == "Value" then TextLabel.Text = IntValue.Value end end)
Local Location = whereevertheintvalueis textLabel.Text = Location.intValue.Value''