Text Not Updating?

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 do you have “text… addedText” on the line before local texto? That would create a error since it’s just there randomly.

1 Like

it didn’t work even after i removed the local line.

Nevermind. It turns out setting the variable directly to the text property wouldn’t work.

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)
1 Like

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.

1 Like

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)

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.