Answered by
4 years ago Edited 4 years ago
It looks like you are trying to get LocalPlayer in non-LocalScript. First, use a LocalScript instead, then fix you need to fix the removal of the fish. You are trying to :Destroy() a table (plrBackpack:GetChildren()). Instead, loop through the table and destroy each fish in it.
Lastly, you should add a check to make sure it’s the player who touches sellPart.
Edit: Oh, I forgot to answer your actual question. To exclude any child, just do something in the loop like: if child.Name ~= “Rod” then child:Destroy() end
01 | local plr = game.Players.LocalPlayer |
02 | local plrBackpack = plr.Backpack |
03 | local sellPart = script.Parent |
05 | sellPart.Touched:Connect( function (hit) |
06 | if not hit:IsDescendantOf(plr.Character) then return end |
07 | local allFish = plrBackpack:GetChildren() |
08 | for _,fish in pairs (allFish) do |
09 | if fish.Name = = 'Fish' then |
(Code not tested, may need to be edited)