Rounding parts' positions

Hello. I am just here to ask, is there any simple script or plugin that would be able to round the positions of multiple parts. I have a game in which I did not care or notice where the parts were placed. Now they are all misaligned by tenths and hundredths. It is also not as simple as going through each part and rounding it since there are many parts. Thank you for any help in advance!

2 Likes

I’m not sure I understand, but if you want to maintain a constant increment between your parts, e.g spaced by .1, you can use Building Tools by F3X plugin.

2 Likes

You can make a Folder called “Parts” and place all the parts that are misaligned

I’ve made a simple script for rounding the positions of the parts.
Make a script inside Workspace.

local PartsFolder = workspace.Parts

for i, part in pairs(PartsFolder:GetChildren()) do
           part.Position = Vector3.new(math.floor(part.Position.X), math.floor(part.Position.Y), math.floor(part.Position.Z))
    end 

Basically what this script does it gets each part of the “PartsFolder” and Rounds the X, Y, and Z to the nearest Integer using math.floor I hope this script helps you.

or you can just Position all the parts like @Xx_FROSTBITExX says.

and also by the way, This topic should be in Scripting Support if you want people to write scripts.

2 Likes
local Places = 1

for _, Part in pairs(workspace:GetDescendants()) do
     if Part:IsA("BasePart") then
          local Divisor = 10 ^ Places
          local Pos = Part.Position
          
          Part.Position = Vector3.new(math.round(Pos.X * Divisor) / Divisor,math.round(Pos.Y * Divisor) / Divisor,math.round(Pos.Z * Divisor) / Divisor)
     end
end

Edit: Paste this code into the command bar in studio.

Change the Places variable according to what decimal place you would like to snap them to. Hope this help! :slight_smile:

2 Likes

Thank you to both of you who suggested the script. I was thinking about math.floor() but I didn’t fully understand how to use it. Thanks!

2 Likes

I know this is an old thread, but I thought I would mention that I just created a plugin to deal with issues like this. You can use it to round off the position (or size, or orientation) of everything selected to set values or a custom value.

2 Likes