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)"
You need to add ".Value" so, it will look like this:
game.Workspace.itemStocks.numberofSoap.Value = game.Workspace.itemStocks.numberofSoap.Value + 1
Paste this into line 9. Have fun scripting!