Hey everyone! I’m currently doing commands on a curtain, I wanted to do that when the curtain is closed, it will take everyone’s “Camera Tool” away. When it is opened again, it will give everyone the tool back. The curtains work with commands, and I want to add this function to them. I tried searching this up but found nothing regarding removing everyone’s tool.
Thanks everyone!
1 Like
It just comes to doing a loop over every player to either clone or destroy the tool.
local toolName = "Camera"
for _,player in pairs(game.Players:GetPlayers()) do
for _,tool in pairs(player.Backpack:GetChildren()) do
if tool.Name == toolName then
tool:Destroy()
end
end
if player.Character:FindFirstChild(toolName) then --This is done in case the player has the tool equipped
player.Character[toolName]:Destroy()
end
end
2 Likes
Hey, thanks for helping! That seems to work. How would I give the players the tool from ServerStorage?
for _, player in pairs(game.Players:GetPlayers()) do
game.ServerStorage.toolName:Clone().Parent = player.Backpack
end
1 Like