Tool stops ClickDetector?

Right so, I’m making a system where a player is required to have a tool equipped once a ClickDetector event has been fired. However, when the player equips the tool the ClickDetector isn’t detected and ignored and when unequipped, it is detected again.


If there is no solution, I was thinking to use the Tool’s clicking event and detect what’s on the player’s mouse. I feel that’s a bit inaccurate though.

3 Likes

Ever since ClickDetectors and Tools were released they’ve never worked with each other, and this is the case for any game that uses both. You could use Proximity Prompts and only accept an interaction when a tool is being held, or go the Activated/Clicked route.

2 Likes

You cant detect Click detectors when a tool is Equipped.

You Need to Interact with the Mouse to Try to do What you want to.

local Mouse = Player:GetMouse()
local ToolEquipped = false

local Tool = script.Parent

Tool.Equipped: Connect (function()
     ToolEquipped = true
end)

Tool.Unequipped:Connect(function()
     ToolEquipped = false
end)

Mouse.Button1Down:Connect(function()
     if ToolEquipped == true then
        print("Tool was equipped and Player Clicked")
   end 
end)
2 Likes

That was my second solution, however I’ll try Proximity Prompts. Thank you for the response.

If it was your second solution and you wont continue the post a anymore, Can you mark my answer a solution?

Thanks :blush:

If you don’t like using Proximity Prompts, you can use the Tool’s Activated event over using a generic mouse click, as Activated will fire if the mouse is clicked while the tool is equipped, and from there you can check if the Mouse’s Target matches the click hitbox.

local mouse = game.Players.LocalPlayer:GetMouse()
local tool = referenceToTheToolHere

tool.Activated:Connect(function()
    if mouse.Target == clickDetectorHitbox then
        -- code
    end
end)

Your call, although proximity prompts are a little bit more user friendly in my opinion :slight_smile:

3 Likes

Much more neat code, thank you for the respose! You made me in love with proximity prompts they are very much better in this situtation for me.

1 Like