This is what I have:
01 | --drgigabyte |
02 | local debounce = false |
03 |
04 | script.Parent.Touched:Connect( function (hit) |
05 | if not debounce then |
06 | debounce = true |
07 | local plr = game:GetService( "Players" ):GetPlayerFromCharacter(hit.Parent) |
08 | if plr then |
09 | plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 10 |
10 | local holders = { plr:FindFirstChild( "Backpack" ), plr:FindFirstChild( "StarterGear" ), hit.Parent } |
11 | for i,v in pairs (holders) do |
12 | pcall ( function () |
13 | for i,v in pairs (v:GetChildren()) do |
14 | if v:IsA( "BackpackItem" ) then |
15 | v:Destroy() |
However every time someone steps on the brick it gives you money even if you don't have any tools.
Im Not sure how to exactly re-script to show you the problem, but if see in this part of the code:
1 | if plr then |
2 | plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 10 |
3 | local holders = { plr:FindFirstChild( "Backpack" ), plr:FindFirstChild( "StarterGear" ), hit.Parent } |
4 | for i,v in pairs (holders) do |
Your giving the money before you are checking if the tool/Item is in their backpack.