Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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!!

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()

This discussion is preserved as it was. New answers, comments, and votes are closed.