I am making a fishing simulator where you get your fish in your inventory, but it won't delete my fish when I touch my sell part, and nor will it give me money(Coins) Btw this is a local script in my sell part.
Here is my code:
local plr = game.Players.LocalPlayer
local plrBackpack = plr.Backpack
local part = script.Parent
part.Touched:Connect(function(hit)
local coinsValue = plr.leaderstats.Coins.Value
if not hit:IsDescendantOf(plr.Character) then return end
for _, Fish in pairs(plrBackpack:GetChildren()) do
if Fish.Name == 'Faceless fish' then
Fish:Destroy()
coinsValue += 5
end
end
end)

1 comment
That doesn't really help me, but I did not know the thing about local scripts