basically what I’m trying to do is add a string of letters to a text however it seems to not work. When i print it; it kind of works
local addedText = "0"
local textButton = script.Parent.TextButton
local text = script.Parent.Parent.Insert.TextLabel.Text
textButton.MouseButton1Up:Connect(function()
text.. addedText
local texto = text.. addedText
print(texto)
end)
Why would setting the Variable directly to the text not work?
local addedText = "0"
local textButton = script.Parent.TextButton
local text = script.Parent.Parent.Insert.TextLabel
textButton.MouseButton1Up:Connect(function()
text.Text = text.Text..addedText
end)
You don’t set the variable directly to the text. They do. Here: local text = script.Parent.Parent.Insert.TextLabel
You get the label.
While they did: local text = script.Parent.Parent.Insert.TextLabel.Text
Although I’m not sure whether it actually doesn’t work when using the second example (I can’t check atm), they’re actually different.
Because with the second example you just saving the Text.
Here is a example:
The Text inside the TextLabel is: "Hey".
If you do local TextLabel = TextLabel and call TextLabel.Text = "Hey2" then you changed the Text to “Hey2”
But if you do local TextLabelText = TextLabel.Text and call TextLabelText = "Hey2" then you didnt changed the Text of the TextLabel but you changed the Text inside the Variable TextLabelText.
Also when the Text of the TextLabel updates, it will not update the Variable, because inside the Variable its just a normal String.
There is no option to save and get the Text instantly from the Roblox Side. (I think)