-
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. -
What is the issue?
The issue is that it didnt worked. Sometine the tomato come 3 times higer then the last ingredient -
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
end
return num
end
p.Touched:Connect(function(hit)
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 = Instance.new("WeldConstraint",bun)
clone.Anchored = false
clone.CanCollide = false
weld.Part0 = bun
weld.Part1 = clone
clone.CFrame = bun.CFrame * CFrame.new(0,getExactSize(tool),0)
clone.Parent = tool
tool.Name = tool.Name ..' + ' .. p.Name
end
end)
Thanks for reading