Check if remote event hasn't been fired for some time?

  1. What do you want to achieve?
    I want the server to be able to check whether or not the client has sent a remote so that they can be kicked if they didn’t.

  2. What is the issue?
    I’m not quite sure how to do it, I got a basic version but it’s not optimal at all as it can cause false kicks.

  3. What solutions have you tried so far?
    I didn’t find any topic here that describes what I am trying to do.

Script (The local script fires every 10 seconds)

local RemoteCheck = {}

ReportRemote.OnServerEvent:Connect(function(player,reason,whatever)
	print("Received")
	if not table.find(RemoteCheck,player.UserId) then
		table.insert(RemoteCheck, player.UserId)
	end
end)

task.spawn(function()
	local Start = tick()
	
	while wait() do		
		while tick() - Start < 30 do
			wait()
			for _,player in pairs(game.Players:GetPlayers()) do
				if not table.find(RemoteCheck, player.UserId) then
					print("Kicked")
				end
			end
		end
		
		Start = tick()
		RemoteCheck = {}
	end
end)

I fixed, for anyone whos’ gonna need that stuff in the future:
basically when the event is received, tick() will be added to a table valued to the player.
The server will check if after 10 seconds (when the next remote should be fired) if the tick is bigger than 15 (to prevent false kicks due to lag), if it still is which it wouldn’t be in case the remote was fired again, the player will be kicked.

ReportRemote.OnServerEvent:Connect(function(player,reason,whatever)
	print("Received")
	RemoteCheck[player.UserId] = tick()
end)

task.spawn(function()
	while wait() do
		for _,player in pairs(game:GetService("Players"):GetPlayers()) do
			if RemoteCheck[player.UserId] and tick() - RemoteCheck[player.UserId] >= 10 then
				if tick() - RemoteCheck[player.UserId] > 15 then
					print("Kicked")
				end
			end
		end
	end
end)
local Table = {}

local function OnRemoteFired(Player)
	local Time = os.time()
	Table[Player] = Time
	task.wait(15)
	if Table[Player] == Time then
		--Remote hasn't been fired for the player in 15 seconds.
	end
end

local function OnPlayerRemoving(Player)
	Table[Player] = nil --Prevents memory leak.
end
4 Likes

Are you able to help me with an issue real quick if you are available? Also, thanks for a reply.