I’m trying to create a cooldown bool value when a skill is used, however when I use the skill the cooldown applies for everybody therefore only 1 person can use the skill at a time.
I can provide some parts of the script if needed, but I used a return function because I’m not really experienced with module scripts, if there’s a better way to activate a module script I wouldn’t mind either.
In that case you’d need a table to hold the values of each player.
local Cooldowns = {}
local function Skill() --Example skill function.
if Cooldowns[Player] then return end --Ignore if player is in a cooldown.
Cooldowns[Player] = true --Start the cooldown for the player.
--Perform the skill.
task.wait(3) --Wait for the length of the cooldown.
Cooldowns[Player] = nil
end
-- How long cool down lasts
local cooldown_time = 3
-- Function
local function Skill(player: Player)
-- Using attributes, but you can also use tables, but REMOVE PLAYER KEY FROM TABLE WHEN PLAYER LEAVES GAME (when using tables)
local last_time = player:GetAttribute("SkillCooldown") or 0
if os.clock() - last_time >= 3 then print("Init Skill") end
end