Two dots punctuation mark is a type-checking feature that recognizes the properties of the class you paste after it, determines the return types of functions and defines the data types. It mitigates the time you spend looking for its properties or children, going back to take a glance at the return type etc. It’s all handled by the descriptive tab while typing. Examples:
type myTable = {
["String"] : string,
["Number"] : number
}
local useMyTable : myTable = {
["String"] = "Hey",
["Number"] = 1
}
local returnElements : () -> (string, number) = function()
return useMyTable["String"], useMyTable["Number"]
end
print(returnElements()) -- Output: Hey 1
What you are doing here is something called Type Checking, by default roblox doesn’t force you to Type Check, however you can if you want and if you want to get really in-depth with it, which can be very good so you don’t run into unwanted bugs (the benefit of type checking) you can at the beginning of the script set the type to —!strict
If you are familiar with other programming languages, specifically JavaScript, then you might be familiar (or you might have heard of) with something called TypeScript. TypeScript is basically just JavaScript with Types.
Anyways, here are the main benefits of doing this:
Like you showed gives you autocomplete
Can get rid of future un-wanted bugs
Can keep your code organized, especially if you are someone who doesn’t like to name your variables something meaningful