Difference between referencing 2 things

So say we have something like:

data.Template = {
XP = 0,
Level = 0

    data.PlayerData[player] = data.Template;

    -- random code
   data.PlayerData[player].XP += 1;


data.PlayerData[player].XP += 1;

be better than

data.PlayerData[player]["XP"] += 1;

This is a random question, and always been bothered by it.

The only time I ever use square brackets for references is when the name contains anything like spaces or dots, for example:

This would return an error:

data.PlayerData[player].Player XP += 1

Whereas this wouldn’t:

data.PlayerData[player]["Player XP"] += 1

Yeah, but I seen once on a post that they recommend [“XP”] not .XP because its supposedly way better, but they didn’t provide reasoning.

The most it can really be is good practice/habit, I can assure you it’s going to have no impact performance-wise or change how anything works.

1 Like

Alright, thank you. I appreciate it :raised_hands: