Mouse buttonclick without a tool nor gui

So I have been trying to make it punch when you click the screen without a Gui or tool (Like in rogue lineage), but I can’t think of an alternative for it. Anybody have a clue?

Make a script in StarterPlayerScripts.
Do :GetMouse() on the player.
For more info on :GetMouse()

And, you can detect when the player clicks.
Place an animation in the script, get the player’s name and go into workspace and find them,
play the animation.

2 Likes

Oh. Thank you very much, I appreciate it.

Surely you have another idea in mind then? It would be helpful to share what you have in mind over posting blankly like this. For example, were you thinking of using UserInputService or ContextActionService to bind actions to certain input types, including mouse inputs, over using the old events of the PlayerMouse?

1 Like

Is there a way to to do it with UserInputService?

Yes, there is. There’s even an example on the wiki.

local function onInputBegan(input, gameProcessed)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		print("The left mouse button has been pressed!")
	end
end

UserInputService.InputBegan:Connect(onInputBegan)

Edit: It looks like you can also do this with ContextActionService. The wiki says “Valid input enum items include those within the following: KeyCode , UserInputType or PlayerAction.”, and UserInputType is how you check for a mouse click. I haven’t tested this, but it should look something like this:

local ContextActionService = game:GetService("ContextActionService")

ContextActionService:BindAction("MouseClick", print, true, Enum.UserInputType.MouseButton1)
3 Likes

Thank you very much. I appreciate it.