Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I round to the nearest 3?

Asked by 7 years ago

The relevant piece of my current code is this:

CurrentBuilding:SetPrimaryPartCFrame(CFrame.new(math.ceil(Mouse.Hit.p.X + 2), math.ceil(Mouse.Hit.p.Y), math.ceil(Mouse.Hit.p.Z + 2)))

How must I alter this to round to the nearest 3?

My intention is to create a grid, with grid spaces 3x3 studs. What methods must I use?

1 answer

Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago

Very simple: math.floor(value/3)*3

0
Note if that doesnt work switch the / and * around. Its pretty late (for me its 01:40) so im not sure. RubenKan 3615 — 7y
Ad

Answer this question