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

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

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

✓ Accepted answer

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

1 comment

0

Tried that, same error. But I appreciate the help. And yes that's what I want to do.

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

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