Burger Stacking/Building System

Im trying to make a burger building system
I want it so when the player drops a, bun, burger, top bun on the plate it stacks on top of each other like
bottom bun then burger then top bun

this is the code but it doesnt really work it only welds when dropped but not how i want it to

im using a grab system for this

script.Parent.Touched:Connect(function(hit)
if hit:IsA(“Part”) or hit:IsA(“MeshPart”) or hit:IsA(“UnionOperation”) and hit:FindFirstChild(“Dropped”) then
while true do
wait(0.0001)
for i, v in pairs(script.Parent:GetTouchingParts()) do
if hit.Dropped.Value == true and v:FindFirstChild(“Dropped”) then
local weld = Instance.new(“WeldConstraint”)
weld.Parent = hit
weld.Part0 = hit
weld.Part1 = script.Parent
break
else
print(“NOT PLACED”)
end
end
end
end
end)

ive tried looking on how to fix it but i cant find anything about it

The size of the plate is 2, 0.4, 2

Formatted code:

script.Parent.Touched:Connect(function(hit)
    if hit:FindFirstChild("Dropped") and (hit:IsA("Part") or hit:IsA("MeshPart") or hit:IsA("UnionOperation") then
        while task.wait() do
            for i, v in pairs(script.Parent:GetTouchingParts()) do
                if v:FindFirstChild("Dropped") and hit.Dropped.Value == true then
                    local weld = Instance.new("WeldConstraint")
                    weld.Part0 = hit
                    weld.Part1 = script.Parent
                    weld.Parent = hit
                    break
                else
                    print("Piece is not placed!", v) -- Most likely will print wrong data
                end
            end
        end
    end
end)

What is your system supposed to do, exactly?

Okay so, you have a plate and you can build a burger using buns and burger patties so i want them to stack on the plate when they touch the plate when you drop them on the plate using the grab system i have
like the pattie stacks on top of the bottom bun and the top bun goes on top of the patties

What is wrong with it though? Are there errors, or visual bugs?

I figured it out changing the positions using Vector3 thank you for your help though

1 Like

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