i have no idea why its not working
local max = 10
local bame = script.Parent.bame.Value
local amt = script.Parent.amt.Value
local sty = script.Parent.styl.Value
script.Parent.Touched:connect(function(item)
if bame.Value == "none" `and amt.Value == s and item.Name == "pat" or item.Name == "tbun" or item.Name == "bbun" or item.Name == "bac" or item.Name == "tom" or item.Name == "che" or item.Name == "let" or item.Name == "pla" or item.Name == "mon" or item.Name == "rat" then
print("added "..item.Name)
bame.Value = item.Name
amt.Value = amt.Value + 1
item:Destroy()
elseif item.Name == "pat" and amt.Value~=max and bame.Value == "Patty" then
amt.Value = amt.Value + 1
sty = "pat"
item:Destroy()
elseif item.Name == "tbun" and amt.Value~=max and bame.Value == "TopBun" then
amt.Value = amt.Value + 1
sty = "tbun"
item:Destroy()
elseif item.Name == "bbun" and amt.Value~=max and bame.Value == "BottomBun" then
amt.Value = amt.Value + 1
sty = "bbun"
item:Destroy()
elseif item.Name == "bac" and amt.Value~=max and bame.Value == "Bacon" then
amt.Value = amt.Value + 1
sty = "bac"
item:Destroy()
elseif item.Name == "tom" and amt.Value~=max and bame.Value == "Tomato" then
amt.Value = amt.Value + 1
sty = "tom"
item:Destroy()
elseif item.Name == "che" and amt.Value~=max and bame.Value == "Cheese" then
amt.Value = amt.Value + 1
sty = "che"
item:Destroy()
elseif item.Name == "let" and amt.Value~=max and bame.Value == "Lettuce" then
amt.Value = amt.Value + 1
sty = "let"
item:Destroy()
elseif item.Name == "pla" and amt.Value~=max and bame.Value == "Plate" then
amt.Value = amt.Value + 1
sty = "pla"
item:Destroy()
elseif item.Name == "mon" and amt.Value~=max and bame.Value == "Cash" then
amt.Value = amt.Value + 1
sty = "mon"
item:Destroy()
elseif item.Name == "rat" and amt.Value~=max and bame.Value == "Rat" then
amt.Value = amt.Value + 1
sty = "rat"
item:Destroy()
elseif item.Name == "unload" then
for i,v in pairs (game.Lighting.Pick:GetChildren()) do
for i = 1,amt.Value do
if v.Name == sty then
b = v:Clone()
b.Parent = workspace.Pick
b.CFrame = CFrame.new(Vector3.new(57.1,5.835,-80))
amt.Value = amt.Value - 1
wait(1.5)
end
end
end
end end)
while true do
wait()
if bame.Value == "tbun" then bame.Value = "TopBun"
elseif bame.Value == "pat" then bame.Value = "Patty"
elseif bame.Value == "bbun" then bame.Value = "BottomBun"
elseif bame.Value == "bac" then bame.Value = "Bacon"
elseif bame.Value == "tom" then bame.Value = "Tomato"
elseif bame.Value == "che" then bame.Value = "Cheese"
elseif bame.Value == "let" then bame.Value = "Lettuce"
elseif bame.Value == "pla" then bame.Value = "Plate"
elseif bame.Value == "mon" then bame.Value = "Cash"
elseif bame.Value == "rat" then bame.Value = "Rat"
end
script.Parent.SurfaceGui.amt.Text = ""..amt.Value.."/"..max
if amt.Value <= 0 then
amt.Value = 0
bame.Value = "none"
end
script.Parent.SurfaceGui.name.Text = bame.Value
end
the script is supposed to fire when something touches the crate, if the name of that thing that touched the crate is one of the names listed above ("pat", "mon", "tom", etc.) then the thing gets destroyed, the bame value gets the things name and the amt value increases by one. after the bame value has been set to that thing, it cant be set to something else until the amt = 0. that was the desired result, but for some reason the crate overwrites the bame value with every item except for "pat" and i have no idea why, could someone explain this to me?
also removing the and amt.Value == 0makes the crate absorb everything including regular parts not listed in the item.Name == "" above

2 comments
also sorry for my messy as heck coe
it seems if i replace
and item.Name == "pat"with the name of another item, then that item is the item that works with the script. :thinking: