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

How does one create a cool down for remote events on the server side?

Asked by 5 years ago

Usually, you can set a local variable to determine whether a cool down is in action and so on preventing players from spamming an event, however exploiters can bypass this and fire the event many times a second, how could I possibly implement a cool down within the server that is specific to that one player and not the rest?

1 answer

Log in to vote
2
Answered by
Despayr 505 Moderation Voter
5 years ago

A Table can be used to do so.

local Cooldown = {}



script.Parent.Touched:Connect(function(hit)

if hit and hit.Parent then
local Character = hit.Parent
if not Cooldown[Character] == false then return end ---If the Character is not in the table, then continue.
Cooldown[Character] = true ---Adds the Character to the table
wait(5)
Cooldown[Character] = false
end
end)

If the Player is not in the table, then add them to it. If they are in the table, then the script will ignore the rest

0
perfect thank you! Marmalados 193 — 5y
Ad

Answer this question