Hello, I have been working on a grid system for my placement game.
This is my code, I want the object to be positioned exactly in 4 stud increments.
game:GetService("RunService").RenderStepped:Connect(function()
local mousePos = mouse.Hit.Position
if math.floor(mousePos.X) % 4 == 0 then
object_position = Vector3.new(math.floor(mousePos.X), 0, math.floor(mousePos.Z))
elseif (math.floor(mousePos.X) + 1) % 4 == 0 then
object_position = Vector3.new(math.floor(mousePos.X - 1), 0, math.floor(mousePos.Z))
elseif (math.floor(mousePos.X) - 1) % 4 == 0 then
object_position = Vector3.new(math.floor(mousePos.X + 1), 0, math.floor(mousePos.Z))
end
placement_object:SetPrimaryPartCFrame(CFrame.new(object_position) * CFrame.Angles(0, math.rad(rotation), 0))
end
end
end
end)