I need to make a script that destroys all the gears in the player's backpack when executed. The script I have made up till now is:
local children = player.Backpack:GetChildren() if (children) then children:Destroy() end
I get this error:
ServerScriptService.RemoteEventsScripts.Client To Server.RelatedToTeams.NeutralTeam:11: attempt to call method 'Destroy' (a nil value)
For problems like that you need to use for loop.
Here is your script:
local Tools = player.Backpack:GetChildren() -- gets the children of the backpack for index, object in pairs(Tools) do if object:IsA("Tool") then -- checks if current child is a tool object:Destroy() -- destroy end end