[Vector3/MoveTo/Position bug] Copy+Pasting custom size brick leaves big gap

This bug started happening somewhat recently. I got reports in my building game about this starting about last week. It might be some Part:MoveTo or Vector3 bug.

Repro:

  • insert a brick
  • custom formfactor
  • end of the y size could be .01 (as shown in picture, it’s 2,1.01,2), .55, .75, etc.
  • visible gap appears.

Reproducible in studio and online.

Does not happen when the y size is an integer.

Ultra annoying when trying to build, especially with my main game being a building game.

If anyone has code that will fix this in the meantime, please share! It’s not as easy as it looks to code and I’m stumped - what if the brick is cframed funny? Or there are parts above it, and I still want to keep the “popping up” effect?

This has been annoying. I made a thread about it 5 months ago, but it doesn’t appear to have gotten much attention. Documentation - Roblox Creator Hub

Can you share the code? Sounds awesome

Also your post had more info in it than mine, nice.

It was something pretty simple like:
local part = game.Selection:Get()[1]
local copy = part:Clone()
copy.Parent = part.Parent
copy.CFrame = part.CFrame + Vector3.new(0,copy.Size.Y,0)

Wouldn’t work for parts turned on their side, so not that awesome, but I’m sure I could figure it out.

[ul]
[li]1st group on the left: The simple y size code + tilted pillar on its side.[/li]
[li]2nd group: The following code taken/edited from qcmdutl. Tilted pillars stack fine![/li]
[li]3rd group: Un-tilted bricks (i.e. the TopSurface points up) work with both your code and qcmdutl the same.[/li]

[/ul]

local NewCFrame = CFrame.new
local bb_points = {
	Vector3.new(-1,-1,-1);
	Vector3.new( 1,-1,-1);
	Vector3.new(-1, 1,-1);
	Vector3.new( 1, 1,-1);
	Vector3.new(-1,-1, 1);
	Vector3.new( 1,-1, 1);
	Vector3.new(-1, 1, 1);
	Vector3.new( 1, 1, 1);
}

local function RecurseGetBoundingBox(object,sides,parts)
	if object:IsA"BasePart" then
		local mod = object.Size/2
		local rot = object.CFrame
		for i = 1,#bb_points do
			local point = rot*NewCFrame(mod*bb_points[i]).p
			if point.x > sides[1] then sides[1] = point.x end
			if point.x < sides[2] then sides[2] = point.x end
			if point.y > sides[3] then sides[3] = point.y end
			if point.y < sides[4] then sides[4] = point.y end
			if point.z > sides[5] then sides[5] = point.z end
			if point.z < sides[6] then sides[6] = point.z end
		end
		if parts then parts[#parts + 1] = object end
	end
	local children = object:GetChildren()
	for i = 1,#children do
		RecurseGetBoundingBox(children[i],sides,parts)
	end
end

local function GetBoundingBox(objects,return_parts)
	local sides = {-math.huge;math.huge;-math.huge;math.huge;-math.huge;math.huge}
	local parts
	if return_parts then
		parts = {}
	end
	for i = 1,#objects do
		RecurseGetBoundingBox(objects[i],sides,parts)
	end
	return
		Vector3.new(sides[1]-sides[2],sides[3]-sides[4],sides[5]-sides[6]),
		Vector3.new((sides[1]+sides[2])/2,(sides[3]+sides[4])/2,(sides[5]+sides[6])/2),
		parts
end

function copystack(part)
	local copy = {}
	local copy_parent = {}
	
	for i,v in pairs({part}) do
		local o = v:Clone()
		copy[i] = o
		o.Parent = workspace
		--copy_parent[o] = workspace
	end

	local cSize,cPos,cParts = GetBoundingBox(copy,true)

	local selection = {part}
	local sSize,sPos
	if #selection > 0 then
		sSize,sPos = GetBoundingBox({part})
	end

	local center = CFrame.new(cPos)
	local new = CFrame.new(sPos + Vector3.new(0,sSize.y/2 + cSize.y/2,0))

	part.CFrame = new:toWorldSpace(center:toObjectSpace(part.CFrame))
end

 copystack(workspace.test1)

Weird angled bricks still copy funny even with studio & qcmdutl, but that’s fine. When building a castle/house, most bricks are level.

Even with this, I’m still lacking the important “pop-up” functionality that .Position does with CanCollide bricks when it copies into another brick. Very useful for clone a bunch of bricks into a tall wall, by just clicking the base a bunch of times. Currently my code can’t do that.

This seems like a Studio issue since, as far as I’m aware, you can’t copy and paste in Client. What do you mean when you say it is reproduceable online?

Create a part sized (2,0.96,2)
Position it at (0,5,4.6)

p = workspace.Part:clone() p.Parent = workspace p.Position = Vector3.new(0, 0.499, 4.6)

Pretty sure that’s something around the lines of how a copy tool works in building games. When that code is run you get this result:

The better to make ladders with.

This is definitely a bug. Thanks for the find!

I think its because the pasted part/object is rounded to the nearest 0.1/0.2 studs that is free of obstructions.

Has anyone else had this bug when using the dragger tools to move an object?

Because I have, but not consistently. It happens with some parts but not others, and I haven’t been able to discern a pattern.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.