I have an npc, which drops meat when killed. That works fine, but the meat is supposed to increase a value and then destroy itself, but it does none of those. How can i fix this? Here is my give value script:
local ting = 0 --debouncer
function onTouched(hit)
if ting == 0 then
ting = 1
check = hit.Parent:FindFirstChild("Humanoid")
if check ~= nil then
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
local stats = user:findFirstChild("MeatFolder")
if stats ~= nil then
local cash = stats:findFirstChild("Beef")
cash.Value = cash.Value + 1
script.Parent:Remove()
wait(2)
end
end
ting = 0
end
end
script.Parent.Touched:connect(onTouched)

2 comments
What is it doing wrong?
It doesn't go away and it doesn't give the value. It prints an error involving the user.