So I' making a script where it would destroy the tool when called, but it wouldn't destroy it. Here's the code:

for i = 1,#PlayersPlaying do --PlayersPlaying is a table of the players playing.
	wait(0.15)
	print("Stick destroyer fired.") --This is so I know that it fired. 
    game.Players[tostring(PlayersPlaying[i])].Character:SetPrimaryPartCFrame(CFrame.new(-56, 8.5, -414)) --Teleports player to a place
	for _, tool in ipairs(game.Players[tostring(PlayersPlaying[i])].Backpack:GetChildren()) do --Loop to check of player has stick.
	if tool.Name == "Stick" then
		print(tostring(PlayersPlaying[i]) .." has a stick!") --Prints if someone has stick
        tool:Destroy()
    	end
	end
end

2 comments

0

Well that depends where the tool is. If you equip a tool for example it won't be on backpack rather it would be on the player character. In this case it would not destroy the tool because there's no tool to destroy. You should also check the player character to see if they have a tool

0

Oh ok. Thanks for the help!