Im quite new to oop, and whilest looking at my peers work people always seem to use get and set functions for setting and getting information outside of a modules class sphere, ive found it much more convenient and less cluttersome to simply index the property with module.Property, but nobody else seems to do this. Is there some issue with directly indexing that i havent yet come accross or are the functions used to keep everything consistent and concise?
Well, roblox doesn’t use getters and setters for properties, for one*. If you set the color of a part you just do Part.BrickColor = …, not Part:SetBrickColor(…).
Setters/getters are mostly useful when you want to enforce certain rules about what a property can be set to (e.g. “this must be between 0 and 1”) or what happens when it changes (e.g. “this should change this other thing when it changes”).
A lot of the times people use setters and getters because they have been told it’s “the right way” to do things, but they’re not always the best choice.
*(As a side note, roblox does actually do other things when you assign a property, like firing Changed events. They use “hidden” getters and setters that can be emulated with the __index and __newindex metamethods if you want to do something similar. Usually setters are simpler.)
So in summary get and set are useful for when you want to modify the data in such a way that it differs from the regular value?