Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Generate perfect box Region3?

Alright I'm trying to generate a box that's 80,40,80 in a region 3 but I get odd sized boxes like 80,40.4,79. Things like that.

This was for a mini map and I wanted to generate a little square of: http://prntscr.com/9gy9q8

Local script in a gui:

function createRegion3(startp, endp, num)
	local region = Region3.new(startp,endp)
	local part = Instance.new("Part",game.Workspace)
	part.Anchored = true
	part.Size = region.Size
	part.CFrame = region.CFrame
	
	for _,Part in pairs(game.Workspace:FindPartsInRegion3(region,nil,100)) do
		print(Part.Name)
	end
end

--x,y
while wait(5) do
	local pos = game.Players.LocalPlayer.Character.Torso.Position
	createRegion3(Vector3.new(pos.X-40,pos.Y-20,pos.Z+40),Vector3.new(pos.X+40,pos.Y+20,pos.Y+40),5)--B2
	print('getting region 3')
end

3 comments

1

Make sure you add part.FormFactor = Enum.FormFactor.Custom otherwise it will be left to default which generates that extra .4 studs or something.

0

^

0

still

1 answer

The region itself is the correct size (you can check by printing it).

The problem is that when you set the .Size on a part, it first consults the part's FormFactor property. The FormFactor tells the part how to round the size out.

If you want to have arbitrarily sized regions, you have to set part.FormFactor = "Custom" before setting the size.

Note that you can't set any dimension to be smaller than 0.2, even with Custom FormFactor.

This discussion is preserved as it was. New answers, comments, and votes are closed.