Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I remove certain tools from EVERY player in the game?

Asked by 6 years ago

I know that THIS removes tools from a certain player.. But what if I want to remove it from every player?

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        if msg == "RemoveTools" then
            plr.Backpack.Tool:Remove()
        end
    end)
end)

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

You can use a loop to iterate through all of the players in the game and destroy their tools.

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        if msg == "RemoveTools" then
            for i,v in pairs(game.Players:GetPlayers()) do
                v.Backpack.Tool:Destroy()
            end
        end
    end)
end)

This is basically what you said except it iterates through all the player's and destroys their tools.

Ad

Answer this question