This script is within a part within a model. The problem is that when you go on test mode and have a script clone the model this script no longer works and only works in the first original model. It also doesn't work if I select it with the roblox select tool while in test mode and clone it. What is the issue?
--give cookie tray (put in inven, remove cookie tray, turn off oven
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local foodinventory = player:FindFirstChild("BakedGoods")
if foodinventory ~= nil then
print("yes")
local alreadyexists = foodinventory:FindFirstChild("ChocChipCookies")
if alreadyexists == nil then
print("yeet")
local tag = Instance.new("NumberValue",foodinventory)
tag.Name = "ChocChipCookies"
tag.Value = tag.Value + 12
else
print("yoot")
alreadyexists.Value = alreadyexists.Value + 12 --instead of making a new value, adds 12 to existing inventory value
end
end
workspace.Oven1.On.Value = false --turn off oven (will make oven w/player id tag attached later)
script.Parent.Parent:Destroy()
end)

4 comments
why are u doing tag.Value = tag.Value + 12 why not just tag.Value = 12?
why don't u show the script that clones this script
well it's just a simple cloning local clone = cookietray:clone(). The cloning goes through, and even if you clone it with studio's select tool the clone will not work like the original.
the clone is the reason this script doesn't work maybe