So i just made a function that is entirely server-sided and about cooldowns it works great and unexploitable due to the value changing on server-side, however i still need feedback on how i can improve it and possibly make it better!
function Engine.CreateCD(Player: Player?)
local __CD = Instance.new("IntValue")
__CD.Parent = Player
__CD.Name = "CD"
end
function Engine.ChangeCD(Player: Player?, CD: IntValue?)
if Player:FindFirstChild("CD") then
CD.Value = 3
coroutine.wrap(function()
if CD.Value >= 0 then
repeat
task.wait(1)
CD.Value -= 1
until CD.Value <= 0
end
end)()
end
end
if PLAYER:FindFirstChild("CD").Value <= 0 then
Engine.ChangeCD(PLAYER, PLAYER:FindFirstChild("CD")) -- Apply cooldown!
print("Test cooldown") -- prints if intvalue (or cooldown) is below 0
end