Tool is not detecting mouse click

Yeah, so if I equip my gear it does not detect any clicks at all and does not print “a 1” or “a 2”

Tool.Equipped:Connect(function(Mouse)
	print("selected")
	print(Mouse)
	Mouse.Button1Down:Connect(function()
		print("a 1")
		if Mouse.Button1Down then
			onMouseDown(Mouse)
		else
			print("FALSE ALARM")
		end
	end)
	Mouse.Button1Up:Connect(function()
		print("a 2")
		if Mouse.Button1Up then
			onMouseUp(Mouse)
		else
			print("FALSE ALARM")
		end
	end)
end)
2 Likes

when it prints the mouse it prints “Instance” I believe that means it works but I do not know anymore.

Can’t you just use:

Tool.Activated:Connect(function()
    print("Hi")
end)
2 Likes

you should be defining the Mouse by game.Players.LocalPlayer:GetMouse(), not in a tool equipped function

2 Likes

Dont use mouse.button1down use activated. Activated is fired when the tool is equipped and the player clicks there screen.

2 Likes

game.Players.LocalPlayer is for local scripts, and this is a regular script. so unfortunately that would not work

1 Like

Use the Activated event.

Example:

Tool.Activated:Connect(function()
Print("Test")
end)

It’s pretty much mouseclick for tools. More info: Activated Event

1 Like

I am using Button1Down because once they let go it will fire the Button1Up event

Also this is what your script should look like :stuck_out_tongue:

Tool.Activated:Connect(function()
Print("Mouse") 
end)

So you are attempting to do so because you want the Button1Up Event?

1 Like

yeah. I honestly do not do a lot of scripting with tools, so I am not sure if there is a better way.

You should try to use a local script and a user input service or just a user input service and some way to get the player.

Which a good way would be getting the player from the equipped event

1 Like

Actually, I think a better way of doing it is this:

Tool.Activated:Connect(function()
--code stuff
end)
Tool.Deactivated:Connect(function()
--more code stuff
end)

I believe this may work but I will test it in 10 minutes since I am currently busy

1 Like

Yup or just use the deactivated option :woozy_face:

1 Like

If you ever need the player in a tool remember you could always get the player character as if the player holds the tool then it will just be in it’s character.

Just some info incase you ever need the player :slight_smile: