I’m trying to get a value from a table like this by using ‘table.find’, however it always seems to return nil.
local valuetable = {
variableA = 25,
variableB = 50,
variableC = 75,
variableD = 100
}
local chosenvalue = table.find(valuetable, "variableC")
Is there any way I can get a number value from the table using the string?
I use a table like the one above for getting a number value from an object, say, damage it will deal. The object changes, so I check it’s name in the table to get the number value to deal damage.
For example, say I had a table like this:
local DMGValues = {
Sword = 25,
Knife = 10,
Axe = 17,
Club = 20
}
And I had the weapon that was dealing damage as a tool. I check the tool’s name in the table, get the damage value somehow and then deal damage with the chosen value.
Inshort, predefining wouldn’t help with what I’m doing.