Value Organization help

Hi there. I am creating a prison game where you have to escape the prison to rob stores etc. On a game I previously worked on with a group, there has been some major organization issues. Mainly because values were splattered everywhere. For my prison game, I need to make values like “arrested”, “innocent”, “isRobbing”, etc, in the player and much more. I know there is something called “attributes”, but that is still not out yet. Is there any other approach I can take on? For example, insert the player in a table similar to the value(pretty sure its expensive and slow because I need to check if the player is in the table with a for loop)? Any response will be appreciated.

1 Like

You can use a map.

local players = {}

local function arrested(player)
        players[player]=“arrested”
end

local function innocent()
        players[player]=“innocent”
end

It stores the values based off of a key so you can recall it quickly. Also the key can be a lot of things like functions which is super useful.

If holding only one state isn’t good enough you can create a map for every state.

1 Like

How can I create a map? Also, is a map just a key but with multiple values?

I finally understand how to assign multiple values to a key! You have to use a dictionary/map.

1 Like