I writing a Cooldown script to prevent player spamming it, but player can still spam it idk why i return the script to dont let player use the move
function MainFunctions.Cooldown(char, SkillName, Duration)
if not char.PrimaryPart:FindFirstChild(SkillName) then
if char:FindFirstChild("GetDamaged").Value == true then
repeat
wait()
until char:FindFirstChild("GetDamaged").Value == false
end
local CDValue = Instance.new("BoolValue", char.PrimaryPart)
CDValue.Name = SkillName
deb:AddItem(CDValue, Duration)
local player = game.Players:GetPlayerFromCharacter(char)
if player then
local CooldownGUI = ClientItemFolder.GUI.CooldownUI:Clone()
CooldownGUI.Parent = player.PlayerGui.CooldownGUI.BackGround
CooldownGUI.Name = SkillName
CooldownGUI.SkillName.Text = SkillName
local tweenInfo = TweenInfo.new(Duration, Enum.EasingStyle.Linear)
local tween = game.TweenService:Create(CooldownGUI.CDBackground.CDBar, tweenInfo, {
Size = UDim2.new(0, 0, 1, 0)
})
tween:Play()
tween.Completed:Connect(function()
CooldownGUI:Destroy()
end)
end
else
return -- this return btw
end
end
this is how i use it btw