I am creating a remote function that returns a value to the client. The issue is that I don't know how to debounce on the server so that the requests don't get spammed. Here is what I have tried so far, but the table would get infinitely large:

local playerDebounceList = {}
-- getData is a remote function I define earlier in the script
getData.OnServerInvoke = function(player, input)
	local specialKey = tostring(player.UserId)
	if not playerDebounceList[specialKey] and tick() - playerDebounceList[specialKey] >= 5 then
		playerDebounceList[specialKey] = tick()
		return input
	end
end

I am really uncertain as to how I would do this without creating a massive table. Thanks!

7 comments

0

Removing players from the table on the PlayerRemoving event would not be ideal, but it is a possibility if all other routes fail.

0

what is input?

0

A string that I will evaluate on the server after I get this debounce working. Don't worry, I am not giving any power to the client.

0

Solved by _@ and Link149 on the discord.

0

Both suggested using Delay.

1

Why was this downvoted?

1

@Phelegethon with that credit awesome