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

Why is this not working? I'm trying to change the text of something!

Asked by 5 years ago
Edited 5 years ago

Hello. I'm using a local script to do this in.

function ChangeText()
    local Text = script.Parent.Text
    Text = "dsadad"
end

ChangeText()

It will not do anything. Please help!

0
What is script.Parent.Text exactly Fad99 286 — 5y
0
Tip, when changing Properties of things, dont reference the Property you want to change inside of the Variable! Hope this helps. AspectType 151 — 5y

1 answer

Log in to vote
0
Answered by
Kymaraaa 116
5 years ago

It's because your variable called Text is directly referencing the Text of your TextLabel/Button. When you go and do

Text = "dsadad"

You're actually changing the variable and not the TextLabel/Button.

function ChangeText()
    local Text = script.Parent
    Text.Text = "dsadad"
end
ChangeText()

The code above will actually change the Text of the TextLabel/Button.

Ad

Answer this question