So I am making a fishing simulator game, and when I try to remove items from a player and give them in-game currency, it won't do either.
Here is my code:
local plr = game.Players.LocalPlayer local plrBackpack = plr.Backpack local sellPart = script.Parent sellPart.Touched:Connect(function(hit)) local money = plr.leaderstats.Coins.Value if not hit:IsDescendantOf(plr.Character) then return end local allFish = plrBackpack:GetChildren() for _, Fish in pairs(allFish) do if Fish.Name == 'Faceless fish' then allFish:Destroy() money = money + 5 end end end)
Do
local plr = game.Players.LocalPlayer local plrBackpack = plr.Backpack local sellPart = script.Parent sellPart.Touched:Connect(function(hit)) local coinsValue = 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.Value += 5 end end end)
By the way, I'm pretty sure this is in a local script.
If you want to change the leaderstats, you would have to use a ServerScript.