Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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.

0
I don't think it is possible. But you can use UserInputService and the Target property of Mouse to detect clicks. User#24403 69 — 5y

1 answer

Log in to vote
-1
Answered by
popeeyy 493 Moderation Voter
5 years ago

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)
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. hiimgoodpack 2009 — 5y
Ad

Answer this question