check if tool is equipped roblox code example

Example: check if tool is equipped roblox

local equipped = false
local tool = script.Parent

tool.Equipped:Connect(function()
    equipped = true
end)

tool.Unequipped:Connect(function()
    equipped = false
end)

-- if you need to check this outside of the one script, you can do this if check or use _G or modules (modules are definitely more recommended than _G especially if you're checking this on the client):
if plr.Character:FindFirstChild("ToolName") and plr.Character["ToolName"]:IsA("Tool") then
    print("equipped")
end

Tags:

Lua Example