I’m trying to break a repeat loop for a stun Timer system but i don’t know how
--//Services
local Run_Service = game:GetService("RunService")
local Replicated_Storage = game:GetService("ReplicatedStorage")
--//Tool
local Tool = script.Parent.Parent
local Sounds = Tool.Sounds:GetChildren()
--//Events
local Events_Folder = Tool.Events
local Damage_Remote = Events_Folder.DamageRemote
--//Values
local Stun_Time = 0
local Stun_Threshold = 0
--//Particles
local Combat = Replicated_Storage.Combat
local Gore = Combat.Gore
--| Main Script |--
function Update_Stun_Time()
if Stun_Time >= 0 then
repeat task.wait(0.1)
print(Stun_Time)
Stun_Time -= 1
until Stun_Time <= 0
if Stun_Time <= -0.1 then
Stun_Time = 0
end
end
end
function Damage_Target(Player, Target, Damage, Body_Part)
local Target_Humanoid = Target.Humanoid
local Stunned = Target:WaitForChild("Stun")
Target_Humanoid.Health -= Damage
Stun_Time = 6
Tool.Sounds.AttackSound:Play()
local Blood_Clone = Gore.Blood:Clone()
Blood_Clone.Parent = Body_Part
Blood_Clone:Emit(50)
Stunned.Value = true
print(Stunned.Value)
if Stun_Time >= 0 then
repeat task.wait(0.2)
print(Stun_Time)
Stun_Time -= 1
until Stun_Time <= 0
if Stun_Time <= 0 then
Blood_Clone:Destroy()
Stunned.Value = false
print(Stunned.Value)
Stun_Time = 0
end
end
end
Damage_Remote.OnServerEvent:Connect(Damage_Target)