Since I’m learning about indexing, I might as well learn what are square brackets and when to use them.
The most common practice of using these brackets are for indexing. Either accessing through instances or, more commonly, tables. Any value inside the brackets represent the index value.
However, instances are usually using their own methods or direct accesses via addressing the name of instances.
so will game.Players[“LocalPlayer”] work the same as game.Players.LocalPlayer because im indexing the local player
They are essentially working the same. If I reckon it correctly, someone had mentioned that there is a minimal difference between that I do not know of as of now.
Apparently, it’s better to use the square brackets when the name contains whitespaces.
Last question periods in lua is indexing also? because in game.Players im getting the players from the current game?
It is the syntax after all. That is correct, but sometimes you don’t use the indexing only and should the instance be replicated later, alternate methods substitutes over it such as game:GetService()
.