So say we have something like:
data.Template = {
XP = 0,
Level = 0
};
game.Players.PlayerAdded:Connect(function(player)
data.PlayerData[player] = data.Template;
-- random code
data.PlayerData[player].XP += 1;
end)
Would
data.PlayerData[player].XP += 1;
be better than
data.PlayerData[player]["XP"] += 1;
This is a random question, and always been bothered by it.
walshuk
(vincenzo)
#2
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.
walshuk
(vincenzo)
#4
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 