This is reposted btw
function module:Breathing(Player,Bool) local Character = Player.Character local plrData = game.ReplicatedStorage.PlayerData:FindFirstChild(Player.UserId) print(CooldownModule:IsOnCooldown(Player.Character,"Breathing")) if Bool and not CooldownModule:IsOnCooldown(Player.Character,"Breathing") and not CooldownModule:IsOnCooldown(Player.Character,"Active") then print(Bool) local Value = Instance.new("StringValue",Character) Value.Name = "Breathing" while Character:FindFirstChild("Breathing") and Bool do if plrData.Breath.Value < 100 then plrData.Breath.Value = plrData.Breath.Value + 1 wait(0.1) end end elseif not Bool and Character:FindFirstChild("Breathing") then CooldownModule:CreateCooldown(Character,"Breathing",0.2) for i, v in pairs(Character:GetChildren()) do if v.Name == "Breathing" then v:Destroy() end end end end
The wait
function is inside the if statement code block. Here's a summary example:
local a=0 while true do--start loop if a==1 then-- since a==0 it skips this if statement wait(0.1);-- since the if statement is skipped, this wait function wont run, there's no cool down because while loops run really fast, thereby causing a timeout end; end;
I suggest placing your wait function outside of the if statement, so that regardless of the condition, there will be a cool down to prevent timeout.