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

Why is the table not working with the variable?

local myTable = {one = Color3.fromRGB(255, 255, 255), two = Color3.fromRGB(0, 0, 0)}
local myVariable = "one"
myTable[myVariable]

How would i make this work. I want it to take the variable from local myVariable not look in the table for myVariable. How would I do this?

1 answer

✓ Accepted answer

Well, your table doesn't define "one" as a string so you have to do

local myTable = {["one"] = Color3.fromRGB(255, 255, 255), ["two"] = Color3.fromRGB(0, 0, 0)}
local myVariable = "one"
myTable[myVariable]

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