Going to keep this brief and to the point, I am trying to make a system that places toppings such as lettuce, tomato, onion, cheese, etc. on a burger in no particular order. So you can you have the patty and put lettuce on and the lettuce will plop itself on the patty.
I’m not particularly good with CFraming, nor Welds so I don’t really know how to fix this issue. The issue is that the topping never actually goes on top, it just stays in the middle of the piece it should be adding onto. Even after changing code up to test it, it just stays in the same spot. To solve this issue, I’ve tried messing around with C0 and C1, but those didn’t help. As well as try making the Vector3 that adds to the CFrame higher, but nothing helped. Here is the code that runs it;
function module:addTopping(model, additive)
--// Model is the burger, and additive is a model in ServerStorage of the topping, which is cloned in later in the code.
if model then
local customCFraming = {
["Bottom Bun"] = Vector3.new(),
["Cheese"] = Vector3.new(),
["Lettuce"] = Vector3.new(0, model.lastAdded.Value.Size.Y / 2, 0),
["Onion"] = Vector3.new() * CFrame.Angles(math.rad(90), 0, 0),
["Tomato"] = Vector3.new(),
["Pickles"] = Vector3.new(),
["Top Bun"] = Vector3.new()
}
if additive == "Bread" then
else
local add = additive:Clone()
local weld = Instance.new("ManualWeld")
weld.Name = add.Name .. " weld to " .. model.lastAdded.Value.Name
add.Anchored = true
add.Parent = model
weld.Part0 = add
weld.Part1 = model.lastAdded.Value
if add:IsA("MeshPart") then
add.CFrame = model.lastAdded.Value.CFrame + customCFraming[add.Name]
elseif add:IsA("Model") then
add:SetPrimaryPartCFrame(model.lastAdded.Value.CFrame + Vector3.new(0, add.PrimaryPart.Size.Y, 0))
else
print (add.ClassName, " this class type needs to be added to the if statement on line 14 of the toppingAdder module")
end
add.Anchored = false
weld.Parent = model.lastAdded.Value
end
end
end
If you have any questions, feel free to post them below. Any help is greatly appreciated!
If I’ve posted this in the wrong category, I’m sorry and let me know! - edit