How I can detect when player used leftclickDown and leftclickUp with serverscript?

The system I want to do is as follows:

Each time the player makes MouseButton1Down, a value will increase in the server, and when MouseButton1Up used, a function working, then the value will be 0. I need use MouseButton1, MouseButton2 and MouseButton3.

but if I use UserInputService, I need use remoteevent but clicks will be too many according to total players and remote events will give an error.

I tried this:
Button Properties:
Server Script: (its only test for me so I used my name)

Local Script:

The system works like this:
Now, every time the player clicks on the button that covers the entire screen of the player, the functions there are triggered, but the player cannot rotate the screen(camera), as a solution, I made visible false with localscript.
In this way, the button that is Visible true on the server will be visible false on the player’s screen, so that the player can rotate the screen and trigger functions.

But the system didn’t work because it doesn’t trigger if Visible is false on the player’s screen.
(Why? I’m using Visible true and Server Script on server)

To solve this problem, I think:
The player should be able to rotate his screen even though there is a button on his screen.
A system where we can use RemoteEvents less is required.
i have to use a different system to use MouseButton1…MouseButton3

1 Like

I was confused on why you rather use events designed for UI objects for Input detection. But then I saw…

Is your current method working detecting a client’s Interaction with UI Within a Serverscript? I don’t believe its possible without using remove events.

Also what did you mean by remote events will give an error?

I’m pretty sure you need a local script to detects client input and to notify the server of what the client has pressed/released you need remote events.

1 Like

but RemoteEvents will drop because too many signals will go, and if we add this to all players, there will be a lot of drops.

Any change from a local Script is not visible from a server script. So even though visible changed on the client, the server is in capable of seeing that. Realistically you’re going to have to use a remote event. unless the players can click ridiculously fast I don’t think you will need to worry about sending too much data, but if you’re still concerned about sending too much data through you can group it so it’ll only send data like a few times a second informing it how many times the player clicked while updating their local counter instantly. But the only way you can manage client-server communication for player input is a remote event. So like 3 times a second or something send how many times the player clicked if you are really sending too much data.

I don’t know what you are referring to can you explain?

if player use makro? I mean : 24click/second.
or what if the player accidentally or intentionally makes 500 clicks a second?

Add a cooldown so that players can’t spam click.

What you do is you store how many clicks the player made since the last time you sent data, and you only send data a few times a second informing the server how many times they clicked. So like this

local clicks = 0

    clicks = clicks + 1
    —make the client update anything visual instantly here if you want. 

While true do
    if clicks > 0 then

Of course that’s assuming you want to allow them to make an absurd amount of clicks per second. Otherwise just a denounce would be better like DataAspect said.

If I add a waiting time, the game has some problems, for example, it loses because it can’t do it right when it should, but even though it does
When I use mousbutton2down, dodge to attack but if I have cooldown sometimes can’t dodge and this turns into error

wait 0.33 second so less for system there are keys that players must apply just in time

Ahh. In this case you don’t actually want to send raw inputs. You want to process the commands on the client to decide what they are trying to do and only send changes to the server when the action the player attempts to take updates. This way you can ignore duplicate actions. So for example, only send a dodge when the player switches to a dodge. If they are spamming dodge though, you can probably ignore most of those because a dodge takes time, so you would just need to send it when dodge is a valid option again.