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
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)
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