0 views0 copies0 likes
Per-Player Interaction Cooldown Module
Universal script
Copy it, then test it in your own Studio place.
Script code
15 lines · 0.4 KBlocal Cooldowns = {}local deadlines = setmetatable({}, {__mode = "k"})function Cooldowns.Try(caller, action, seconds) local state = deadlines[caller] or {} deadlines[caller] = state local now = os.clock() local remaining = (state[action] or now) - now if remaining > 0 then return false, remaining end state[action] = now + math.max(seconds, 0) return true, 0endfunction Cooldowns.Clear(caller) deadlines[caller] = nilend-- …open Get script for the full sourceAbout this script
Create a ModuleScript named Cooldowns and call its Try method from interaction handlers. Give each action a key and a minimum interval. The module remembers deadlines separately for each caller and action, and returns remaining seconds to display feedback. Use a Player instance as the caller and call Clear when resetting that player's interactions. Start with a low-stakes use such as a shop greeting.
Log in to leave a comment.
No comments yet
Be the first to share your thoughts!
Comments
Share what works, ask questions, or report an issue.