I am struggling to activate all my tools by mouse clicking it but only 1 tool worked while I'm equipping many tools at once. This is my script to activate all tools but it need to be executed in the executor:
for i,v in pairs(game:GetService("Players").LocalPlayer.Backpack:GetChildren())do if v.ClassName == "Tool" then v.Parent = game:GetService("Players").LocalPlayer.Character end end for i,v in pairs(game:GetService("Players").LocalPlayer.Character:GetChildren())do if v.ClassName == "Tool" then v:Activate() end end
There's a few things that you need to do to make this work
First of all, use the function Humanoid.EquipTool
instead of setting the tool's parent.
Second, you should only use one loop instead of 2. If you want to activate every single tool, you can just unequip (Humanoid.UnequipTools()
) the current tool before looping through them.
And finally, use wait()
between equipping and activating, and also before equipping a new tool.
local player = game.Players.LocalPlayer player.Character.Humanoid:UnequipTools() for i,v in pairs(player.Backpack:GetChildren())do if v:IsA("Tool") then player.Character.Humanoid:EquipTool(v) wait() v:Activate() end wait() end
If you want to know more check out the devhub.