Using double colon :: when initialising variables in a function

I’ve seen in alot of different places in youtube videos and in other people’s work they sometimes use a double colon :: normally in OOP when working with classes.

Is it a way to tell roblox that a variable has a specific set of indexes depending on it’s class?
image

for example here (i dont know how to use the double colon) i am trying to tell roblox that my plr variable is from the class Player which i want the indexes and properties of Character, UserID and such without having to type the entire thing out.

One example of what im trying to achieve could be here

How do i do this properly? And am i even correct when i say this is the intended use?

Thanks

3 Likes
-- both of these are of type BasePart
local part : BasePart = Instance.new("Part")
local part = Instance.new("Part") :: BasePart

-- take string "foo" or "bar" as argument and return string
local function foo(FooOrBar : "foo" | "bar") : string
return "foo" .. FooOrBar
end

local function doSomething(player : Player) -- take a player as argument
end

heres a good video about type annotation

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.