Round 0.001 to 0?

This misfortune hit me in my latest build wherein a number of parts have magically moved upward 0.001 studs. I’ve encountered this before but this time it’s on too large of a scale to bother with manually, and was hoping to find a solution to round the position of any part off by 0.001 to the nearest whole?

Many thanks.

1 Like

if you want to round down every time then - math.floor(Number)
if you want to round up every time then - math.ceil(Number)
if you want to round to the nearest whole number every time then - math.round(Number)

hope this helps

any way I can select all parts and then run an action to move any item thats x.001 to x?
Would also need to apply to x.xx1s as well, just chop the third decimal point off if it’s on the Y axis and has a value of 1

?

1 Like

can I have an example on what you mean?

basically there’s this infrequent glitch in studio where complicated moves have defects resulting in a 0.001 discrepancy

if I move a part that’s at Y axis 10 it’ll go to Y axis 10.001 for some unknown reason

anyway, this has happened to a few hundred of my parts and it’s too complicated to identify them (would take me hours to check all my parts) so I was hoping for a quick solution.

I mean I would give a script that would use math.floor on all parts

but I don’t know which parts need to be fixed, because if I math.floor on something that has let’s say had 10.5 then it would go to 10, which is bad

You can just select all of the parts that moved up by 0.001 and drag it down.

Also is it really that noticeable? 1/1000th of a stud is an incredibly small gap so IDK how you even notice. If it doesn’t ruin the project I’d just leave it alone.

1 Like

The reason why 0.001 is a bad number is because it may throw off OP’s building grid.

1 Like

it’s surprisingly noticeable, and I know I can select all parts manually but the map has thousands of parts and I’d have to search through them all individually to catch each one.

I have encountered this too, but for me it was limited only to parts that had their faces on the exact same plane causing Z-index fighting and the render engine not knowing which face to render, causing flickering.

This happened on glass for an escalator. I only noticed it after unioning the glass, I got around this by unioning the glass parts together with a large part cutting off the top 0.05 studs of the faces, leaving a perfectly flat surface. This probably won’t work for you since it’s around the whole map.

I have a suspicion that this might not be a glitch, but I’m not sure. I think the slight edge is nearly invisible and this stops Z-index fighting as mentioned before.


Either way, I made a quick script to do this, but I seriously advise you to NOT use this, this works for parts that have their orientation in strictly 90-degree increments, otherwise any part oriented differently WILL be moved in an unwanted direction causing the same gap to appear, for example, any roof.

Either way, this is the best I can do. If you want, add a check for the orientation if it divides by 90, and if not, don’t edit the position.

image

Use at your own risk, I suggest you make a backup of the map before using too, or better, don’t use it at all and live with the small gaps that actually help you by hiding Z-index flickering.

for i, v in pairs(game.Workspace:GetDescendants()) do
	if v:IsA("BasePart") then
		local x,y,z = v.Position.X, v.Position.Y, v.Position.Z
		x = math.floor(x*100)/100
		y = math.floor(y*100)/100
		z = math.floor(z*100)/100
		
		v.Position = Vector3.new(x,y,z)
	end
end
1 Like

Here’s a script I developed that rounds the position of everything selected to the closest 0.125 studs. Its part of a local plugin toolbar I made that has a number of set rounding values that I can hit to round position and scale.

I am a big fan of working in grids when doing environments, it just makes everything so much neater and easier to work with (for me anyway). I actually use this script a lot while working to keep everything in order.

If you want to round the position to a different value, just change the local ALIGNMENT value from 0.125 to what you want. I normally have a button for 0.125 and 0.25 rounding.

1 Like

I turned the script I posted and some others into a full Studio Plugin for rounding off Position Scale and Orientation in Studio.
Should work nicely on your problem.

1 Like