for some reason the game freezes for like 10 seconds when i fireserver the cdgui script, and the counter doesnt want to go down
and it doesnt want to destroy after its finished counting
game:GetService("ReplicatedStorage").CooldownGui.OnServerEvent:Connect(function(player, movename, countdown, localorglobal)
local chr = player.PlayerGui
local timer = countdown
local gui2 = game:GetService("ServerStorage")["CDGui"]:Clone()
gui2.Parent = chr
chr.CDGui.Name = "cooldown"
local gui = chr.cooldown
local cdtimer = gui.MainFrame.Cooldown.Text
gui.MainFrame.MoveName.Text = movename
cdtimer = countdown
cdtimer.Enabled = true
coroutine.resume(coroutine.create(function()
repeat until timer == 0
wait(1)
timer = timer - 1
cdtimer = cdtimer - 1
end))
wait(countdown)
gui:Destroy()
end)
im not sure what is wrong with the code tho

3 comments
it almost fully works but the timer text still doesnt change
Does line 8 refer to a text-label's text? Or is there an object under Cooldown called text? If it's the former, then you're making a mistake. Remove '.text', and whenever you want to change the text (like on line 11) do cdTimer.Text.
i found the problem, the local for the counter text changed gui instead of gui2