Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I equip a tool and still be able to click blocks with click detectors?

Basically, when I make a tool and equip it, the cursor is black, so now I can't use the click detectors present in the blocks needed to be clicked. Is there anyway I can fix this? Thanks.

1 comment

0

I don't think it is possible. But you can use UserInputService and the Target property of Mouse to detect clicks.

1 answer

✓ Accepted answer

You can't. You should use the player's mouse object for this. Here is a wiki example:

Link: https://developer.roblox.com/api-reference/event/Mouse/Button1Down

Code (I edited it a bit.):

local Tool = script.Parent --make sure this is a Tool object
 
Tool.Equipped:Connect(function(Mouse)
	Mouse.Button1Down:Connect(function()
		print("Button1Down")
		local Target = Mouse.Target

		if Target then
			print("Player Clicked", Target)
		end
	end)
end)

1 comment

0

You never disconnect the Button1Down connection, causing it to print multiple times when equipped and dequipped multiple times. You should also just use Tool.Activated to simplify it.

This discussion is preserved as it was. New answers, comments, and votes are closed.