How to fix float points with placement system

I need to fix float points issues with CFrames, as it’s meaning blocks are janky when placed, and also for data saving purposes (I don’t wanna save a dozen random numbers, when all I need is a single number)

I tried to create this function, but I get Invalid number of arguments: 4 on FixedCFrame, and I also worry that this would break my slabs. Every block is 3x3x3, but slabs are 3x1.5x3, and fear it could break their placement. Either way though, this doesn’t work. I need all numbers of the CFrame to be like this too, as when I rotate parts, their lookvectors and what not also go off
image

function Helpers.FloatFix(cFrame)
	local Position = Vector3.new(
		math.floor(cFrame.Position.X),
		math.floor(cFrame.Position.Y),
		math.floor(cFrame.Position.Z)
	)
	
	local LookVector = Vector3.new(
		math.floor(cFrame.LookVector.X),
		math.floor(cFrame.LookVector.Y),
		math.floor(cFrame.LookVector.Z)
	)
	
	local RightVector = Vector3.new(
		math.floor(cFrame.RightVector.X),
		math.floor(cFrame.RightVector.Y),
		math.floor(cFrame.RightVector.Z)
	)
	
	local UpVector = Vector3.new(
		math.floor(cFrame.UpVector.X),
		math.floor(cFrame.UpVector.Y),
		math.floor(cFrame.UpVector.Z)
	)
	
	local FixedCFrame = CFrame.new(
		Position,
		LookVector,
		RightVector,
		UpVector
	)
	
	return FixedCFrame
end
print("New", NewCFrame)
local FixedCFrame = Helpers.FloatFix(NewCFrame)
self.CurrentBlock:PivotTo(FixedCFrame)

New 6, 3.00099993, 5000, 1, 0, 0, 0, 1, 0, 0, 0, 1

there is probably some clever math way, and if there is please reply but you could try this

local function fixFloatError(x)
  return tonumber(string.split(tostring(x))[1])
end

I’m not sure if this works in lua, but you can divide any number by one and it should fix floating point.

It does work, but not all the time. It depends how long the number is.

Instead of setpivot, why not just setting the CFrame? If its a model, make a primary part and do :SetPrimaryPartCFrame

Because it is a model. SetPrimaryPartCFrame is deprecated, in favor of PivotTo()

Wait, i had no idea setprimarypartcframe is deprecated
Off to fix all my games