Using math.floor with position

I’m creating a sleigh to fly around my map, but when trying to use math.floor it gives me this error:
Workspace.Att.Sleigh:15: invalid argument #1 to 'floor' (number expected, got Vector3)
Code:

local TweenService = game:GetService("TweenService")
local timea = time()
local total = 20

while true do
	local att = 1
	local model = workspace.Sleigh
	local start = model:GetPrimaryPartCFrame()
	while time() - timea <= total do
		local End = game.Workspace.Att["Attachment"..att].WorldCFrame
		local TI = TweenService:GetValue((time() - timea)/total, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
		local CFrame2 = start:Lerp(End,TI)
		model:SetPrimaryPartCFrame(CFrame2)
		model:SetPrimaryPartCFrame(CFrame.lookAt(model.PrimaryPart.Position, script.Parent.Attachment1.WorldPosition))
		if math.floor(model.PrimaryPart.CFrame.Position-game.Workspace.Att["Attachment"..att].WorldCFrame.Position) == 0 then
			att = att + 1
			local total = 20
			local timea = time()
		end
		wait()
	end
end```

It says it in the error.

math.floor only takes numbers not Vector3 values (positions) you’ll have to floor each position individually

2 Likes

You tried to use the method on a Vector3, while the accepted argument is a Number.
Consider doing this instead:

local vector = Vector3.new(10.5, 10.3, 10.7);
vector = Vector3.new(math.floor(vector.X), math.floor(vector.Y), math.floor(vector.Z))
1 Like