Can you automatically press the mouse with a script?

Is it possible to press the mouse with a script like
which fires all the mouse.Button1Down etc events?
If so, how would this be performed?

1 Like

For security reasons you can’t and shouldn’t be able to simulate inputs like mouse button presses.

The most you can do is call the event listeners you connect the events to.

Why do you want to do this though?

1 Like

I don’t think this is possible on lua but it is possible to do it on python (i can tell you the document of it if you want to)

Yea I don’t think that can be performed with lua.

Yes, you can, though you would have to make a remoteEvent that is called “MouseClick” (For click detector) or “MouseButton1Click”(for Ui), you will need to look more into remote events here:

you might also have to put a variable into the remote event called player

1 Like

Uh i don’t think you understand what I’m trying to do, I want it to automate a mouses click, without remotes.

You can’t automate a mouse click without remote events

1 Like

Then it’s not automating lol you’re just firing remote events.

If you could override player inputs, then by now scammers and exploiters would be using it to make players click on stuff like purchasing dialogs, etc. It shouldn’t be possible on Roblox, and for good reason.


Thanks, and that’s understandable just checking because I don’t want exploiters to be able to activate my mouse events!

It is not possible.
You could use Mouse.Enter (or was it Entered?) to connect a function.
Not sure if you can reposition the mouse tho.

not reposition the mouse, it was the automate click, you know the mouse object has events hooked to it like mouse.Button1Down or mouse.Button1Up forcefully triggering those events without calling remote events was my idea.

Yea i know.
That is the thing that you can’t do.
So the only forceful way i could think of is firing event when you move the mouse or hover it on something.

You can set up your own button system

local module = {};
local methods = {};
methods.__index = methods;

function, text)
    local newButton = {};
    newButton.Name = name;
    local ButtonInstance ="TextButton");
    ButtonInstance.Text = text;
    newButton._btn = ButtonInstance;
    local Bind ="BindableEvent");
    newButton.Clicked = Bind.Event;
    newButton._event = Bind;
    setmetatable(newButton, methods);
        ButtonInstance.MouseButton1Down:Connect(function() Bind:Fire();end);
    return ButtonInstance;

function methods:Click()

return module;

other scripts

local ButtonModule = require(Module)

local NewButton ="btn", "hello world");


NewButton:Click(); --< Should fire the bindable event and output "O"

if I understood what you’re going for, you can listen for normal hover events on the button then fire the click event .


Why not just put the function outside the connect event? If you put the function outside the connect event, you would be able to fire that function

sorry, i don’t speak english very well

You can always pretend they are clicking the mouse by getting their hit and position… If you are doing a tutorial you can pretend to lock the mouse to the desired position and make sure the code runs even though they didn’t click…

Hope this makes sense.


Easy.Just copy whatever is inside MouseButton1Click function and past where you want to do it istead of player

I am not looking for an OOP-Metatable sort of thing it’s basically just to emulate a mouses click

You didn’t read properly. Please read it again.

That isn’t the idea. Thanks for an idea though.