I’m trying to make a box delivery system, but it’s not working Could someone help me? I made a tool called “Green Box”, the right thing would be, whenever I spend it with the part, I would earn 10 Money and it would disappear from my inventory, but when I pass it through the part I do not earn 10 money .
local Players = game:GetService("Players")
local dinheiroChunk = script.Parent
local function onPartTouch(hum)
local partParent = hum.Parent
local h = partParent:FindFirstChild("Humanoid")
local backpack = Players.LocalPlayer.BackPack
local box = backpack:FindFirstChild("Green Box")
if box then
local player = Players:GetPlayerFromCharacter(partParent)
local leaderstats = player.leaderstats
local dinheiroStats = leaderstats:FindFirstChild("Dinheiro")
if dinheiroStats then
dinheiroStats.Value = dinheiroStats.Value + 10
end
end
end
dinheiroChunk.Touched:Connect(onPartTouch)