--[[]	if mobile_is == false then
		mobile_is = true
		mobile_button = script.Parent.ParryButton
		mobile_button.Parent = plr.PlayerGui.PunchGui
	end

	mobile_button.MouseButton1Click:Connect(function()
		humanoid = plr.Character.Humanoid
		if humanoid.Parent.Parry.Value == false then
			humanoid.Parent.Parry.Value = true
			oldspeed = humanoid.WalkSpeed
			humanoid.WalkSpeed = 4
			pstart = humanoid:LoadAnimation(animation.Parry.pstart)
			pstart:Play()
			ppidle = humanoid:LoadAnimation(animation.Parry.pidle)
			ppidle:Play()
		else
			humanoid.Parent.Parry.Value = false
			humanoid.WalkSpeed = oldspeed
			ppidle:Stop()
			pstart:Stop()
		end
	end)]]

end)


script.Parent.Unequipped:Connect(function()
	attach.Parent = script.Parent
	motor6d:Remove()
	idle:Stop()
	equip:Stop()
	if humanoid.Parent.Parry.Value == true then
		humanoid.Parent.Parry.Value = false
		humanoid.WalkSpeed = oldspeed
		ppidle:Stop()
		pstart:Stop()
	end
end)

local i = 1
local deb = false

script.Parent.Activated:Connect(function()
	if humanoid.Parent.Parry.Value == false then
	if deb == false then
		deb = true
		if i == 1 then
			p1 = humanoid:LoadAnimation(animation.Punches.p1)
			p1:Play()
			i = 2
				wait(.2)

			Hitbox:HitStart() 
			attach.swing:Play()
			attach.swing.PlaybackSpeed = .8
			p1.Stopped:Wait()
			Hitbox:HitStop() 
			deb = false
			attach.swing:Stop()
		elseif i == 2 then
			p2 = humanoid:LoadAnimation(animation.Punches.p2)
			p2:Play()
			i = 3
				wait(.2)

			Hitbox:HitStart() 
			attach.swing:Play()
			attach.swing.PlaybackSpeed = 1.1
			p2.Stopped:Wait()
			Hitbox:HitStop() 
			deb = false
			attach.swing:Stop()
		elseif i ==3  then
			p3 = humanoid:LoadAnimation(animation.Punches.p3)
			p3:Play()
			i = 4
				wait(.2)

			Hitbox:HitStart() 
			attach.swing:Play()
			attach.swing.PlaybackSpeed = 1
			p3.Stopped:Wait()

			Hitbox:HitStop() 
			deb = false
			attach.swing:Stop()
		elseif i ==4  then
			p4 = humanoid:LoadAnimation(animation.Punches.p4)
			p4:Play()
			oldspeed = script.Parent.Parent.Humanoid.WalkSpeed
			humanoid.WalkSpeed -= 10
			i = 1
				wait(.4)
				humanoid.AutoRotate = false
			Hitbox:HitStart() 
			attach.swing.PlaybackSpeed = .8
				attach.swing:Play()
				wait(.3)
				game.ReplicatedStorage.CamShakeEvent:FireClient(plr)
				attach.ground:Play()
			p4.Stopped:Wait()
			Hitbox:HitStop() 
			humanoid.WalkSpeed = oldspeed
			deb = false
			attach.swing:Stop()
			end
			humanoid.AutoRotate = true
		end
	end
end)

game.ReplicatedStorage.Parry.OnServerEvent:Connect(function(plr,parent)
	humanoid = plr.Character.Humanoid
	if parent == script.Parent then
		if humanoid.Parent.Parry.Value == false then
			humanoid.Parent.Parry.Value = true
			oldspeed = humanoid.WalkSpeed
			humanoid.WalkSpeed = 4
			pstart = humanoid:LoadAnimation(animation.Parry.pstart)
			pstart:Play()
			ppidle = humanoid:LoadAnimation(animation.Parry.pidle)
			ppidle:Play()
		else
			humanoid.WalkSpeed = oldspeed
			ppidle:Stop()
			pstart:Stop()
			wait(1)
			humanoid.Parent.Parry.Value = false
		end
	end
end)
