I'm trying to make it so a player can grab a box and bring it to a destination.. (I'm a noob to scripting) I would like to add "1" to a NumberValue when a box is delivered (I'd also like to remove the Box from the inventory after touch) this is what I have:
local debounce = false
script.Parent.Touched:Connect(function(hit)
if not debounce then
debounce = true
local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if plr then
local holders = {plr:FindFirstChild("Backpack"), plr:FindFirstChild("StarterGear"), hit.Parent}
game.Workspace.itemStocks.numberofSoap = game.Workspace.itemStocks.numberofSoap + 1
for i,v in pairs(holders) do
pcall(function()
for i,v in pairs(v:GetChildren()) do
if v:IsA("BackpackItem") then
v:Destroy()
end
end
end)
end
end
wait(60)
debounce = false
end
end)
However I get an error in the output saying "20:47:44.955 - Workspace.End.Script:10: attempt to perform arithmetic on field 'numberofSoap' (a userdata value)"

2 comments
numberofSoap is a NumberValue, not a number value. NumberValues and all things you'd see in the Explorer are objects and cannot be added with another number (This is like adding "Apple" with 100, doesn't make sense right?). You need to get numberofSoap's value and add 1 onto it.
This has been answered, please mark it as answered. Thank you.