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

attempt to index global 'TextLabel' (a nil value) Help?

Asked by 8 years ago

Code is :

Instance.new("TextLabel", script.Parent)
print("Text Made")
TextLabel.name = text
text.Text = ("426emosewaeht yb edam tpirs txet"):reverse()

Error : Players.Player1.PlayerGui.ScreenGui.Script:3: attempt to index global 'TextLabel' (a nil value) Whats wrong here?

2 answers

Log in to vote
1
Answered by 8 years ago

Your problem is that you never set a variable! so it's nil because it doesn't know what it's looking for! So try this!!

label = Instance.new("TextLabel", script.Parent)--label is now the variable.
print("Text Made")
label.name = text--replaced "textlabel" with label as it was not defined.
text.Text = ("426emosewaeht yb edam tpirs txet"):reverse()

Hope this helped!!

Ad
Log in to vote
0
Answered by 8 years ago

I suggest using Variable to prevent this sort of stuff from Happening.

local Label = Instance.new("TextLabel", script.Parent)
    print("Text Made")
    Label.TextLabel.name = text
    Label.Text = ("426emosewaeht yb edam tpirs txet"):reverse()

Answer this question