Why is this script not removing starterpack weapons from the player's backpack?

I made a script that is supposed to remove a player’s weapons when they join the game or die. Despite all other weapons being removed, the starterpack weapons stay in there. I have tried different methods such as putting a 10 second wait to give them time to spawn, making the script wait for the them using waitforchild. However, none of these methods have worked.

Localscript btw:

    --//By shish_kebab4
local plr = game.Players.LocalPlayer
local s = plr.Backpack:WaitForChild("Sword")
local p = plr.Backpack:WaitForChild("Pistol")


game.Players.PlayerAdded:connect(function(player)
	if plr.Backpack:FindFirstChild("Sword") then
	local bpweapons = plr.Backpack:GetChildren()
	for i,v in pairs(bpweapons) do
		print(v.Name)
		if player.StarterGear:FindFirstChild(v.Name) then
		v:Destroy()
		
		else
			
			
		local clone = v:clone()
		   clone.Parent = player.StarterGear
		      v:Destroy()
		end
	end
	end
end)


plr.CharacterAdded:connect(function()
	    local bpweapons = plr.Backpack:GetChildren()
	for i,v in pairs(bpweapons) do
		v:Destroy()
	end
	end)
1 Like

This should go in a server script (script). Once the local script loads, PlayerAdded is not going to be fired because the player joins the game before the script loads. Depending on where you put the local script, CharacterAdded won’t fire either. Also remember to remove the first three lines.

where should it be to fire CharacterAdded?

It’s also worth noting that when the player equips the tool, that tool will be transferred from the Backpack into the player’s Model automatically.

You should check if the tool is in either the Backpack or the player’s character model.

StarterPlayerScripts

Unlike StarterCharacterScripts, the contents in this folder won’t be reset/destroyed upon death,
since they’re not linked to the player’s character.

StarterGear is cloned from the server because the tools need to replicate. StarterGui is locally cloned because it should not need to be replicated. StarterGear is also not for individual people. To do that, you would need to put copies of the tools in their inventory manually on spawn (or remove them but it would be better to just not put them there in the first place).