Hello guys i have a script for tool removing but i get this error on output
local player = game:GetService("Players")
local backpack = player:WaitForChild("Backpack")
local removableLaunchers = {"SledgeHammer"}
local function purgeLaunchers(container)
for _, launcher in pairs(removableLaunchers) do
local tool = container:FindFirstChild(launcher)
if tool and tool:IsA("Tool") then
tool:Destroy()
end
end
end
purgeLaunchers(backpack)
purgeLaunchers(player)
local backpack = player:WaitForChild("Backpack") for second line the outputs says infinity yield possible how to solve this?

4 comments
If this works be sure to mark it as the answer!
infinite yield problem is solved but it says stack end at line 2, so script is not working
Alright, let me review. Could you post the new script? And is this a local script or server script? Also, don't do :WaitForChild('Backpack'). Just do player.Backpack
you couuld do player:FindFirstChild("Backpack")