Question about Function format

I have never seen a function constructed like this first line.
I can’t find another example.

  • Can someone explain it to me? …Especialy the
    : Vector3
    at the end?
function getSurfaceFacingDirection(surfacePointFrom: Vector3, surfacePointTo: Vector3): Vector3
	local translation = surfacePointTo - surfacePointFrom
	local translateDir = translation.Unit --This goes through the sphere. We want this, except perpendicular to the surface normal.

	local surfaceNormal = (surfacePointFrom - ball.Position).Unit
	local rightVector = translateDir:Cross(surfaceNormal) --This will be perpendicular to surface normal *and* the facing direction
	local facingDirection = rightVector:Cross(surfaceNormal) --This will be perpendicular to surface normal and rightVector. That means it's out result!

	return facingDirection.Unit
end

Thanks…

They are type annotations. They just tell the engine (and the reader) that this function takes two Vector3s as arguments and returns a Vector3.

They’re optional but sometimes help improve code clarity.

That’s referred to as typecasting, as its namesake suggests you are casting a specific type onto a parameter before an argument has been passed to it. It’s exclusive to Luau and not found in native Lua.

Thanks guys,
And for the quick response.