What does this symbol mean in luau?

What does “::” and “->” mean in luau? Because sometimes I saw this on people’s script.

1 Like

local variables, function arguments and function return types using : as a separator: and Function types are specified using the arguments and return types, separated with -> :

But I see some even using double :, that’s why I write “::”

Those two symbols are used for type checking. The :: is called assertion, basically gives the current value a type.

local value = workspace.Value :: Part

-> is used for function returns

local myFunc: () -> boolean

For more information, there is a post with almost all information about type checking

1 Like

So basically :: is like for giving a variable or variables a type?

:: is used to give the current value a type.
Let’s say when indexing a property.

local Part = workspace.Part :: Part
if (Part :: Tool).Value then

end

(Part :: Tool) tells autocomplete that Part is a Tool, even though we just told it that its a Part.

image

Outside the :: Tool, it autocompletes as Part

After the :: Tool, it autocompletes as Tool

Ahhh I see, even if part is just regular part but if you use :: it can like autocomplete or autofill into the type that you wrote after :: , so it’s gonna be the same if you say like Part :: GuiObject , it’s gonna autocomplete GuiObject type, okay okay I see, thank you.