What does // do?

So basically when I was making a grid based placement system off of a youtube tutorial, there was this code in module script:

local GRID_SIZE = 4

local PlacementValidator = {}

function PlacementValidator.SnapToGrid(pos : Vector3)
	return Vector3.new(
		pos.X // GRID_SIZE,
		pos.Y // GRID_SIZE,
		pos.Z // GRID_SIZE
	) * GRID_SIZE
end

return PlacementValidator

I couldn’t figure out what // does. I’ve searched up on internet and forum, but no results are to be found. The video said it has something to do with division, but I couldn’t figure out what form of it

its just the same as / or am i wrong

No, it theoretically should do something else

Floor division. When a and b are numbers,

a // b

is equal to

math.floor(a / b)
3 Likes

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