Update RateLimit.luau

Prevent halting of the code execution.
This commit is contained in:
Bl4ise 2024-05-02 12:59:00 +02:00 committed by GitHub
parent 0fb349fe0f
commit ed73b66dc9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -13,11 +13,14 @@ function RateLimit.create(Identifier: string, entrance: number?, interval: numbe
Event:SetAttribute(Identifier.."_ent", entrance)
Event:SetAttribute(Identifier.."_int", interval)
else
while (not Event:GetAttribute(Identifier.."_ent")) or (not Event:GetAttribute(Identifier.."_int")) do
task.wait(0.5)
end
entrance = tonumber(Event:GetAttribute(Identifier.."_ent"))
interval = tonumber(Event:GetAttribute(Identifier.."_int"))
task.spawn(function()
repeat
task.wait(0.5)
until Event:GetAttribute(Identifier.."_ent") or Event:GetAttribute(Identifier.."_int")
entrance = tonumber(Event:GetAttribute(Identifier.."_ent"))
interval = tonumber(Event:GetAttribute(Identifier.."_int"))
end)
end
local entrances: number = 0
return function(incoming: number?): boolean
@ -31,4 +34,4 @@ function RateLimit.create(Identifier: string, entrance: number?, interval: numbe
end
end
return RateLimit :: typeof(RateLimit)
return RateLimit :: typeof(RateLimit)