What exactly does dividing a parts size by 2 help with

Something i dont really understand right now but was making a random part script for a area in a part and made this

Part.Position = (T.CFrame * CFrame.new(
		math.random(-T.Size.X/2, T.Size.X/2),
		math.random(-T.Size.Y/2, T.Size.Y/2),
		math.random(-T.Size.Z/2, T.Size.Z/2)
	)).Position

Nothing wrong with the script, just dont understand why without the /2 it scales like .5x more of both ends of whatever axis

Could someone lmk what im missing

Imagine that you have a square part (this works with any part though, this is for simplification). If we want to find a random position within the part, that position will have two limits on each axis (a lower one and a higher one). Since it’s a square, the same limits will apply for all 3 axis, so let’s analyse just one (the X axis):

Starting from the centre, if we want to reach one of the edges, we need to move half of the size of the square to reach one, so we’ll move 1/2 of the part’s size to get there.

Those 2 limits (for each axis) I mentioned earlier are the two sides of one axis of the square. Let’s
The upper and lower X limit’s will therefore be:

--As mentioned earlier, we start from the centre of the square (square.Position.X)
local upperXLimit = square.Position.X + square.Size.X / 2 
local lowerXLimit = square.Position.X - square.Size.X / 2

Hope that helps!

2 Likes

oh i didnt know it started from the center, thanks for letting me know :smiley: :+1: