I want to stop the wait when the count is 2 but i don’t know how to and need help how to do it
game.ReplicatedStorage.Combat.Gripp.OnServerEvent:Connect(function(Player,HitPlayer,Debounce,count)
if HitPlayer.Character.Humanoid.Health >= 0 then
print(Debounce)
local Char = Player.Character
print(HitPlayer)
local HitChar = HitPlayer.Character
if count >= 2 then
anime2:Stop()
anime:Stop()
end
HitPlayer.Character.HumanoidRootPart.Anchored = false
if count == 1 then
anime = HitChar.Humanoid:LoadAnimation(script.HitPlayer)
anime2 = Player.Character.Humanoid:LoadAnimation(script.PlayerHit)
game.ReplicatedStorage.Combat.Gripp1:FireClient(HitPlayer,HitPlayer)
Char = Player.Character
print(HitPlayer)
HitChar = HitPlayer.Character
HitPlayer.Character.HumanoidRootPart.Orientation = Vector3.new(89.9,HitPlayer.Character.HumanoidRootPart.Orientation.Y,HitPlayer.Character.HumanoidRootPart.Orientation.Z)
Player.Character.Humanoid.WalkSpeed = 0
Player.Character.Humanoid.JumpPower = 0
spawn(function()
local health = HitChar.Humanoid.Health
while Debounce == false do
wait()
HitChar.Humanoid.Health = health
print("E")
end
end)
for index, joint in pairs(HitPlayer.Character:GetDescendants()) do
if joint:IsA("Motor6D") then
joint.Enabled = true
end
end
HitPlayer.Character.HumanoidRootPart.Anchored = true
HitPlayer.Character.RagDoll.Value = true
HitPlayer.Character.Knocked.Value = true
HitPlayer.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp,false)
HitPlayer.Character.Humanoid.AutoRotate = false
for i,v in pairs(HitPlayer.Character:GetDescendants()) do
if v:IsA('BallSocketConstraint') then
v:Destroy()
end
end
for i,v in pairs(HitPlayer.Character:GetDescendants()) do
if v:IsA('Attachment') then
if v.Name == "Attachment" then
v:Destroy()
end
end
end
HitPlayer.Character.HumanoidRootPart.Anchored = false
anime:Play()
anime2:Play()
wait(3) -- i want to stop wait if count >= 2 so how can i do that?
print(count)
print("stop")
if anime2.IsPlaying and Debounce == false then
Player.Character.Humanoid.WalkSpeed = 16
Player.Character.Humanoid.JumpPower = 50
HitChar.Humanoid.Health = 0
anime:Stop()
end
elseif count >= 2 then
if HitPlayer.Character.Humanoid.Health >= 0 then
Debounce = true
Player.Character.Humanoid.WalkSpeed = 16
Player.Character.Humanoid.JumpPower = 50
anime2:Stop()
HitPlayer.Character.HumanoidRootPart.Anchored = false
anime:Stop()
HitPlayer.Character.Humanoid.AutoRotate = false
for index, joint in pairs(HitPlayer.Character:GetDescendants()) do
if joint:IsA("Motor6D") then
socket = Instance.new("BallSocketConstraint")
a1 = Instance.new("Attachment")
a2 = Instance.new("Attachment")
a1.Parent = joint.Part0
a2.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a1
socket.Attachment1 = a2
a1.CFrame = joint.C0
a2.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
joint.Enabled = false
HitPlayer.Character.HumanoidRootPart.Orientation = Vector3.new(89.9,HitPlayer.Character.HumanoidRootPart.Orientation.Y,HitPlayer.Character.HumanoidRootPart.Orientation.Z)
HitPlayer.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
HitPlayer.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp,false)
end
end
end
end
end
end)