Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

[Solved]How can I debounce a remote function when returning a value?

Asked by 5 years ago
Edited 5 years ago

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!

0
Removing players from the table on the PlayerRemoving event would not be ideal, but it is a possibility if all other routes fail. User#21908 42 — 5y
0
what is input? User#19524 175 — 5y
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. User#21908 42 — 5y
0
Solved by _@ and Link149 on the discord. User#21908 42 — 5y
View all comments (3 more)
0
Both suggested using Delay. User#21908 42 — 5y
1
Why was this downvoted? User#19524 175 — 5y
1
@Phelegethon with that credit awesome LegitimatlyMe 519 — 5y

Answer this question