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.
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.
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)
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