CFrame returns NAN values

Hello! As I was placing down the finishing details for my placement system implementing increments, I came into an issue where X and Z values would display NAN values spontaneously. I’m not sure how, as I have had no prior experience with NAN values before, but I believe it has something to do with how I run computations the same time as I set the CFrame property. Any help and insight is really appreciated!

			local angles = CFrame.Angles(0, 0, 0)
			local cframe =, Settings.xIncrement), raycast.Position.Y + ghost.PrimaryPart.Size.Y/2, snapPos(raycast.Position.Z, Settings.zIncrement))
			if cframe ~= cframe then
--SnapPos function
local function snapPos(num, inc)

return math.round(num / inc)*inc



Turns out NAN was being returned since I was computing an operation which divided X and Z by 0. I rectified this by dividing it by one instead