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

How can I find a variable without using its name directly?

So I want to do this

["Dmg"..num]

But Dmg isnt a variable. Theres Dmg1,Dmg2, and Dmg3. I used num to express which damage I want to be used for different attacks but I cant use it the way I showed because Dmg doesnt have a parent. Is there a way to do this?

1 answer

✓ Accepted answer

You can not 100% do this in lua.

The only way this would be possible is if you use a Table to store your values, and use Keys like local DmgTable = {Dmg1 = 10, Dmg2 = 20, Dmg3 = 30}

Then you'll be able to get them using DmgTable["Dmg"..num] with num being 1,2 or 3 in this example.

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