How to get the player mouse FAST!

You would normally use remote functions as it is the safest and best way to get the mouse, but the thing is it takes time to get and my fast paced game cant have the unfair delay in it, is there anything i could do?

Maybe using player:getMouse() ?

local Players = game:GetService("Players")

local player = Players.LocalPlayer

local mouse = player:GetMouse()

local function onMouseMove()
	print("mouse screen position: ", mouse.X, mouse.Y)
end

mouse.Move:Connect(onMouseMove)
1 Like

Well, if i use RemoteEvents hackers can easily put in a Characters Position and have basically aimbot.

1 Like

How about Contextactionservices then?

local contextActionService = game:GetService("ContextActionService")
local mouse = contextActionService:GetMouseLocation()

Im talking about getting it server side.

There is basically no way to prevent this. Since mouse is given from the client, like anything else given from the client it can be exploitable. It is quite hard to match with these exploits, but your best friend is to spam a ton of sanity checks and detect when the players behavior is weird.

Also never use remote functions using :OnClientInvoke because your allowing the client to do what they please basically. Use remote events

1 Like

If your concern is Aimbots you could check after a player kills someone to see how accurate the shot was. If the shot was 100% accurate for the last 3 players then ban the player.

You could also implement a reporting system, though that could have some abuse issues.

1 Like

A mouse is local sided, because its a position of a side from a player, that is only made for the player (local). And server cant take the mouse until you use a Remote, else it wont work

1 Like

Pass the mouse to the server if need be, do any sanity-checks you see fit. To prevent the delay, make sure you handle the effects first on the client so it appears instant and there is no noticeable delay. Preferrably do the same for all other clients and keep the backend-related stuff on the server itself.