What Colon/Two dots mean in code?

I found a script but when I saw it and tried to learn from it I got more confused. :thinking:

What do you mean by “:” where the variables are?
Is it just getting complicated or is it necessary to do all that?
Why does he do that?

My only doubt is the variables that he uses in the function, not the code.

Weird Variables Function

type FilterType = "Blacklist"|"Whitelist"
local function findPartsInGuiObject(guiObject: GuiObject, filterList: {Instance}?, filterType: FilterType?): {BasePart}
	
	local a = guiObject.AbsolutePosition
	local b = guiObject.AbsolutePosition + guiObject.AbsoluteSize
	
	print(guiObject.AbsolutePosition, guiObject.AbsoluteSize, b)
	
	--- make sure a is the top left and b the bottom right
	a, b = Vector2.new(math.min(a.X, b.X), math.min(a.Y, b.Y)), Vector2.new(math.max(a.X, b.X), math.max(a.Y, b.Y))
	
	filterType = filterList and filterType or "Whitelist"
	filterList = filterList or (filterType == "Blacklist" and {}) or workspace:GetDescendants()
	
	local isBlacklist = filterType == "Blacklist"
	local isWhitelist = filterType == "Whitelist"
	
	local instances: {BasePart} = {};

	local rel, x, y
	for _, instance: BasePart in ipairs(isWhitelist and filterList or workspace:GetDescendants()) do
		
		local point, onScreen = camera:WorldToScreenPoint(instance.Position)
		
		if not onScreen then
			continue
		end
		
		--- if FilterType is Blacklist check if the instance is a Descendant or not and skip if so
		if isBlacklist then
			local skip = false
			for _, blacklistedInstance: Instance in ipairs(filterList :: {Instance}) do
				if instance == blacklistedInstance or instance:IsDescendantOf(blacklistedInstance) then
					skip = true
					break
				end
			end
			
			if skip then
				continue
			end
		end
		
		if a.X < point.X and point.X < b.X and a.Y < point.Y and point.Y < b.Y then
			table.insert(instances, instance);
		end
	end
	
	return instances;
end 

I’ve never seen this used in lua but I think it is the argument type.

1 Like

That is called DataType Check.

4 Likes

The thing before colon is an argument name. The thing after is its type. I think…

1 Like

That will help me a lot, thanks!

I use it pretty often, by the way.