How to put a part on top of another?

  1. What do you want to achieve?
    I am working on a burger game, and i have to make a script that put like the meat on top of the last ingredient.

  2. What is the issue?
    The issue is that it didnt worked. Sometine the tomato come 3 times higer then the last ingredient

  3. What solutions have you tried so far?
    . I tried using :GetMass but it didnt worked.

local p = script.Parent -- This is the ingredient
local function getExactSize(tool) -- This is the function that put the ingredient on top
	local t = tool:GetChildren()
	local num = 0
	for _,v in pairs(t) do
		if not v:IsA("BasePart") then continue end
		num += v.Size.Y
	return num
	if hit.Parent:IsA("Tool") then
		if string.match(hit.Parent.Name,p.Name) or string.match(hit.Parent.Name:lower(),p.Name:lower()) then return end
		local bun = hit.Parent:FindFirstChild"Handle"
		local tool = hit.Parent
		local y = bun.Position.Y
		local clone = p:Clone()
		local weld ="WeldConstraint",bun)
		clone.Anchored = false
		clone.CanCollide = false
		weld.Part0 = bun
		weld.Part1 = clone
		clone.CFrame = bun.CFrame *,getExactSize(tool),0)
		clone.Parent = tool
		tool.Name = tool.Name ..' + ' .. p.Name

Thanks for reading :smiley:

Maybe unanchor the next topping and then anchor it again after a delay?

Make sure the Y axis of the part’s size you are using to offset the new part is the thinnest. You might be setting the new offset to the diameter of the part instead of the thickness.

It already unanchored because of the ‘WeldContstraint’

I think its because your calculating the height incorrectly, instead just create a temporary model and get the height using GetExtentsSize().

local function getHeight(Tool)
   local TempTool = Tool:Clone()
   local TempModel ="Model")
   local Height = nil

   TempTool.Parent = TempModel
   Height = (TempModel:GetExtentsSize()).Y

   return Height/2

Then change this line:

clone.CFrame = bun.CFrame *,getHeight(tool),0)