This is to prevent exploiters from firing the remote too many times to cause lag. Is this a workable solution, or can it lead to problems for players?
local event = game.ReplicatedStorage.Event
local working = false
event.OnServerEvent:Connect(function()
if working then return end
working = true
-- do stuff
task.wait()
working = false
end)
Server-sided floodchecks would end up acting for everyone, thus an exploiter could flood a RemoteEvent preventing any other client from legitimately using it, you could use a player debounce table to circumvent this.
RemoteEvent:FireServer() --Client fires server.
local PlayerDebounces = {}
RemoteEvent.OnServerEvent:Connect(function(Player)
if PlayerDebounces[Player] then return end
PlayerDebounces[Player] = true
print(Player.Name)
task.wait(5) --Debounce length
PlayerDebounces[Player] = nil
end)
This can then be converted into a method for catching potential exploiters, be wary of false positives however.
RemoteEvent:FireServer() --Client fires server.
local PlayerDebounces = {}
RemoteEvent.OnServerEvent:Connect(function(Player)
if PlayerDebounces[Player] then
if tick() - PlayerDebounces[Player] <= 0.5 then --Client firing the RemoteEvent too frequently?
Player:Kick() --Kick the player.
end
end
PlayerDebounces[Player] = tick()
print(Player.Name)
end)