so i searched around the devforum for how to make the userinputservice serversided and i have found the solution,
its simple you just send all the inputs to the server but im worried that if some player used a macro it would rapidly send it to the server and basically lag the server. so thats the issue will sending the input lag the entire server due to the remote events?
Yes, lots of events will spawn lots of threads which will cause lag. You can combat this by putting rate limits on RemoteEvents coming from players. You could limit a player to sending fewer than 10 input-related remotes per second, which I think is reasonable for most games.
Yeah, userinputservice is client sided for a reason. Don’t do anything on the client that could be exploited, you don’t need to send every input to the server.
You can do it this way to create a shared limit for all events going through InputBegan, but you could also use this with contextactions or inputended events by routing them through the same function.
function ActualInputHandler(...)
--Your actual input logic here
end
local eventsPerSecondLimit = 10
local events = {}
--Initialize events list
for i = 1, eventsPerSecondLimit do
events[i] = tick()
end
function RateHandler(...)
--Check rate limiting
--Time of input
events[#events + 1] = tick()
--Limit length of recorded events to 10
if #events > eventsPerSecondLimit then
table.remove(events, 1)
end
--How fast were the last 10 inputs given?
local delta = events[#events] - events[1]
print("Delay: " ..delta)
if delta > 1.0 then
print("Sending")
ActualInputHandler(...)
else
print("TOO fast. Slow down!")
end
end
UserInputService.InputEnded:Connect(RateHandler)