For example, if I have a punching script and I do not want it to activate if a player has a tool equipped.
When you equip a tool, the tool's parent gets set to your character.
You can use a loop and check if there is a tool inside the player's character.
repeat wait() until game.Players.LocalPlayer.Character:IsDescendantOf(workspace) local Character = game.Players.LocalPlayer.Character function CHECK_TOOL(character) for _, v in pairs(character:GetChildren()) do if v:IsA("Tool") then print("tool found!") return true end end end function PUNCH() if not CHECK_TOOL(Character) then -- code end end
local tool = character:FindFirstChildWhichIsA("BackpackItem") if tool then -- the character has a tool equipped else -- the character does not have a tool equipped end
This is the proper way to check for an equipped tool. It will detect tools as well as hopperbins. This works because both the Tool and HopperBin classes inherit the "BackpackItem" abstract class.
Insert this script inside your handle.
tool = script.Parent.Parent tool.Equipped:connect(function() print("Tool Equipped") end)