A similar method that tends to be more clean is to just set the value nil after a set amount of time like so:
local remote = game.ReplicatedStorage.RemoteEvent
local tab = {}
local cooldown = 4
remote.OnServerEvent:Connect(function(player)
if not tab[player.UserId] then
tab[player.UserId] = true
-- do whatever you want, but you might
-- want to wrap it in a pcall just in case
task.wait(cooldown)
tab[player.UserId] = nil
end
end)
It’s a method that works pretty well as long as the cool down isn’t too long.