Output Mouse Click

I need help with a Mouse click output so like if you click the output says

“Mouse Clicked!”

And I’m unsure how to do this.

When your holding the tool named “Burnt Sword”

Do you mean with a click detector from a part, holding a tool and clicking, or just clicking without holding a tool?

Yeah I forgot to state that sorry

Put this in a server script

script.Parent.Activated:Connect(function()
	print("Mouse Clicked!")
end)

Is that all? How would the scirpt know it’s from the tool

Whenever you have the tool and click it says that in output

Activated only applies to a tool, so when a player holds then tool and left clicks then it connects to that function.

Tools have an event called “Activated”. This event fires whenever a player clicks and has a tool equipped. For this example I’m going to say that the tool is within the Workspace.
First we have to find the tool:

local tool = game.Workspace["Burnt Sword"]

The reason this variable looks odd is because the tool name has a space in it, therefore we have to find it using strings.
Then we listen for the “Activated” event.

tool.Activated:Connect(function() -- when the tool in the variable before is activated
     print("Mouse Clicked!") -- print "Mouse Clicked!"
end)

for the record the way @temporaryacount101’s script would know what the tool was if you put it in the tool. If you look in the first line it says script.Parent.Activated, meaning that when the parent of the script is activated, the function would fire. Sorry if I’m not making sense.

No you actually make sense thanks for the feedback!

No Problem, happy to help. happy scripting

1 Like