This script is a request tracker for users that limits the number of requests a player can send within a certain period. This script helps prevent too frequent requests from players, improving the security and stability of the server.
Initializing the tracker: The function RequestTracker.new(cooldown, maxRequests) creates a new tracker with specified values of cooldown time (default 10 seconds) and maximum number of requests (default 3).
Request tracking: The method trackRequest(player) tracks requests from the player.
If the player sends a request for the first time, a record is created with the current time and request counter.
If requests continue within the cooldown time, the request counter is incremented.
If the number of requests exceeds the allowed limit, the cooldown time is doubled, and the player is kicked out with a notification.
A method for checking active players with an exceeded number of requests
function self.getPlayersWithExceededRequests()
local players = {}
for player, data in pairs(self.requestCount) do
if data.count > self.maxRequests then
table.insert(players, player)
end
end
return players
end
So does it have a purpose? Or it’s just an idea you posted.
Also I reread the post and it’s not even a global debounce. It just kicks the player if they send too many requests, with the default being 3 requests every 10 seconds (???).
So if a player in my game swings their tool more than 3 times in 10 seconds, boom they are kicked…
Id like to see what the request was for. As @batteryday said, there’s not a very good reason I can think of why this would be for all remotes versus per remote.
Exactly. Remote logic should be handled on a per remote basis. And if you handle it correctly you don’t need to put any fancy trackers on it that kick players. Nothing will happen if the player spams the remote.