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

Is there a way I could use the Text of a TextLabel to call upon a table's contents?

Asked by 5 years ago

I had tried this, doesn't seem to work.

Error: attempt to call global 'Elements' (a table value)

EqFrame.Desc.Text = Elements(item.Text).Description

Anybody have any ideas on how I can do this? I'd much appreciate it.

2 answers

Log in to vote
1
Answered by
Velsity 218 Moderation Voter
5 years ago

If I understand your question correctly, you wanna access a table to change the text on a label to the value that the table has.

You would use [ and ] to access it and not ( and ).

EqFrame.Desc.Text = Elements[item.Text].Description
0
Tried that, same error. But I appreciate the help. And yes that's what I want to do. SevenDevelopment 2 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
--// Variables
local TextLabel = script.Parent:WaitForChild("TextLabel")
local Desc = script.Parent:WaitForChild("Desc")

--// Tables
local Text = {["Info"] = {["Description"] = "Description?"}}

Desc.Text = Text[TextLabel.Text].Description

Answer this question