1

Hello guys i am trying to add Divisions to a game but there is a problem with tables, do you guys know how to solve this?

local divisonName = result3[i].name
print(divisonName)
ESX.Divisions[result3[i].owner].divisonName = {}

it's the code it should get division name and create a table with that like this (we assume divisonName gonna return swat for example):

["police"] = {
    ["swat"] = {
        },
    },

but instead of putting division name as SWAT it will put divisionName variable i already print that divisionName variable and console return me SWAT so everything is fine with logic and value of variable but i guess there it's syntax issue i am not sure! Console Debug image

1 Answer 1

1

Note that in Lua the construct some_table.field is a syntactic sugar for some_table["field"]. Whatever is written after the dot will be treated as a string key.

In your case, to index by the value stored in the variable, you need to write ESX.Divisions[result3[i].owner][divisonName], and not as .divisionName.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much you saved me <3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.