--


script.Parent.OnServerEvent:Connect(function(p)
	local Character = p.Character
	local Humanoid = Character.Humanoid
	local RootPart = Character.HumanoidRootPart
	local torso = Character.Torso
	local RArm = Character["Right Arm"]
	local LArm = Character["Left Arm"]
	local anim = Humanoid:LoadAnimation(script.Punch)
	local anim3 = Humanoid:LoadAnimation(script.BD)
	local FX = Assets.Punch3:Clone()
	anim:Play()
	Humanoid.WalkSpeed = 10
	Humanoid.JumpPower = 0
	Humanoid.AutoRotate = false
	RootPart.Anchored = true
	FX.CFrame = torso.CFrame * CFrame.new(0,-3,-2)
	FX.Parent = workspace.Effects
	wait(0.2)
	local dust = Assets.Dust.Attachment:Clone()
	FX.CanCollide = false
	FX.CastShadow = false
	FX.Anchored = true
	FX.Parent = workspace.Effects
	FX.Transparency = 1
	FX.CFrame = torso.CFrame * CFrame.new(0,-3,-2)
	dust.Parent = RootPart
	wait(0.05)
	local hitcontent = workspace:GetPartBoundsInBox(FX.CFrame, Vector3.new(19.5, 22, 19.5))
	local hitlist = {}
	for _,v in pairs(hitcontent) do
		if v.Parent:FindFirstChild("Humanoid") and v.Parent ~= Character then
			if not hitlist[v.Parent.Humanoid] then
				hitlist[v.Parent.Humanoid] = true
				local RootPart2 = v.Parent.HumanoidRootPart
				script.Parent.Parent.Parent.Part1.Part2.Motor6D.Part1 = RootPart2
				anim3:Play()
				local vel = Instance.new("BodyVelocity", v.Parent.Torso)
				vel.MaxForce = Vector3.new(1,1,1) * 1000000;
				vel.Parent = v.Parent.Torso
				vel.Velocity = Vector3.new(1,1,1) * p.Character:WaitForChild("HumanoidRootPart").CFrame.LookVector * 0
				vel.Name  =  "SmallMoveVel"
				game.Debris:AddItem(vel,2)
				for _,Particles in pairs(dust:GetDescendants()) do
					if Particles:IsA("ParticleEmitter") then
						Particles:Emit(Particles:GetAttribute("EmitCount"))
					end
				end
				wait(0.01)
				wait(0.5)
				local dust = Assets.Dust.Attachment:Clone()
				FX.CanCollide = false
				FX.CastShadow = false
				FX.Anchored = true
				FX.Parent = workspace.Effects
				FX.Transparency = 1
				FX.CFrame = torso.CFrame * CFrame.new(0,-3,-2)
				dust.Parent = RootPart
				wait(0.05)
				local hitcontent = workspace:GetPartBoundsInBox(FX.CFrame, Vector3.new(19.5, 22, 19.5))
				local hitlist = {}
				for _,v in pairs(hitcontent) do
					if v.Parent:FindFirstChild("Humanoid") and v.Parent ~= Character then
						if not hitlist[v.Parent.Humanoid] then
							hitlist[v.Parent.Humanoid] = true
							local HitCounterRemote = RS.Events.Remotes.HitCounter
							HitCounterRemote:FireClient(p)
							local anim2 = v.Parent.Humanoid:LoadAnimation(script.Hit)
							anim2:Play()
							local vel = Instance.new("BodyVelocity", v.Parent.Torso)
							vel.MaxForce = Vector3.new(1,1,1) * 1000000;
							vel.Parent = v.Parent.Torso
							vel.Velocity = Vector3.new(1,1,1) * p.Character:WaitForChild("HumanoidRootPart").CFrame.LookVector * 0
							vel.Name  =  "SmallMoveVel"
							game.Debris:AddItem(vel,2)
							local HitFX = Assets.Headbutt.Attachment:Clone()
							local Head = v.Parent.Head
							HitFX.Parent = Head
							HitFX.Hit:Play()
							for _,Particles in pairs(HitFX:GetDescendants()) do
								if Particles:IsA("ParticleEmitter") then
									Particles:Emit(Particles:GetAttribute("EmitCount"))
								end
							end
							for _,Particles in pairs(dust:GetDescendants()) do
								if Particles:IsA("ParticleEmitter") then
									Particles:Emit(Particles:GetAttribute("EmitCount"))
								end
							end
							game.Debris:AddItem(HitFX,3)
							wait(0.01)
						end
					end
				end
				wait(0.45)
				local dust = Assets.Dust.Attachment:Clone()
				FX.CanCollide = false
				FX.CastShadow = false
				FX.Anchored = true
				FX.Parent = workspace.Effects
				FX.Transparency = 1
				FX.CFrame = torso.CFrame * CFrame.new(0,-3,-2)
				dust.Parent = RootPart
				wait(0.05)
				local hitcontent = workspace:GetPartBoundsInBox(FX.CFrame, Vector3.new(19.5, 22, 19.5))
				local hitlist = {}
				for _,v in pairs(hitcontent) do
					if v.Parent:FindFirstChild("Humanoid") and v.Parent ~= Character then
						if not hitlist[v.Parent.Humanoid] then
							hitlist[v.Parent.Humanoid] = true
							local HitCounterRemote = RS.Events.Remotes.HitCounter
							HitCounterRemote:FireClient(p)
							local anim2 = v.Parent.Humanoid:LoadAnimation(script.Hit)
							anim2:Play()
							local vel = Instance.new("BodyVelocity", v.Parent.Torso)
							vel.MaxForce = Vector3.new(1,1,1) * 1000000;
							vel.Parent = v.Parent.Torso
							vel.Velocity = Vector3.new(1,1,1) * p.Character:WaitForChild("HumanoidRootPart").CFrame.LookVector * 0
							vel.Name  =  "SmallMoveVel"
							game.Debris:AddItem(vel,2)
							local HitFX = Assets.Headbutt.Attachment:Clone()
							local Head = v.Parent.Head
							HitFX.Parent = Head
							HitFX.Hit:Play()
							for _,Particles in pairs(HitFX:GetDescendants()) do
								if Particles:IsA("ParticleEmitter") then
									Particles:Emit(Particles:GetAttribute("EmitCount"))
								end
							end
							for _,Particles in pairs(dust:GetDescendants()) do
								if Particles:IsA("ParticleEmitter") then
									Particles:Emit(Particles:GetAttribute("EmitCount"))
								end
							end
							game.Debris:AddItem(HitFX,3)
							wait(0.01)
						end
					end
				end
				wait(0.45)
				local dust = Assets.Dust.Attachment:Clone()
				FX.CanCollide = false
				FX.CastShadow = false
				FX.Anchored = true
				FX.Parent = workspace.Effects
				FX.Transparency = 1
				FX.CFrame = torso.CFrame * CFrame.new(0,-3,-2)
				dust.Parent = RootPart
				wait(0.05)
				local hitcontent = workspace:GetPartBoundsInBox(FX.CFrame, Vector3.new(19.5, 22, 19.5))
				local hitlist = {}
				for _,v in pairs(hitcontent) do
					if v.Parent:FindFirstChild("Humanoid") and v.Parent ~= Character then
						if not hitlist[v.Parent.Humanoid] then
							hitlist[v.Parent.Humanoid] = true
							local HitCounterRemote = RS.Events.Remotes.HitCounter
							HitCounterRemote:FireClient(p)
							local anim2 = v.Parent.Humanoid:LoadAnimation(script.Hit)
							anim2:Play()
							local vel = Instance.new("BodyVelocity", v.Parent.Torso)
							vel.MaxForce = Vector3.new(1,1,1) * 1000000;
							vel.Parent = v.Parent.Torso
							vel.Velocity = Vector3.new(1,1,1) * p.Character:WaitForChild("HumanoidRootPart").CFrame.LookVector * 0
							vel.Name  =  "SmallMoveVel"
							game.Debris:AddItem(vel,2)
							local HitFX = Assets.Headbutt.Attachment:Clone()
							local Head = v.Parent.Head
							HitFX.Parent = Head
							HitFX.Hit:Play()
							for _,Particles in pairs(HitFX:GetDescendants()) do
								if Particles:IsA("ParticleEmitter") then
									Particles:Emit(Particles:GetAttribute("EmitCount"))
								end
							end
							for _,Particles in pairs(dust:GetDescendants()) do
								if Particles:IsA("ParticleEmitter") then
									Particles:Emit(Particles:GetAttribute("EmitCount"))
								end
							end
							game.Debris:AddItem(HitFX,3)
							wait(0.01)
						end
					end
				end
				wait(0.3)
				local dust = Assets.Dust.Attachment:Clone()
				FX.CanCollide = false
				FX.CastShadow = false
				FX.Anchored = true
				FX.Parent = workspace.Effects
				FX.Transparency = 1
				FX.CFrame = torso.CFrame * CFrame.new(0,-3,-2)
				dust.Parent = RootPart
				wait(0.05)
				local hitcontent = workspace:GetPartBoundsInBox(FX.CFrame, Vector3.new(19.5, 22, 19.5))
				local hitlist = {}
				for _,v in pairs(hitcontent) do
					if v.Parent:FindFirstChild("Humanoid") and v.Parent ~= Character then
						if not hitlist[v.Parent.Humanoid] then
							hitlist[v.Parent.Humanoid] = true
							local HitCounterRemote = RS.Events.Remotes.HitCounter
							HitCounterRemote:FireClient(p)
							script.Parent.Parent.Parent.Part1.Part2.Motor6D.Part1 = nil
							RootPart.Anchored = false
							Humanoid.WalkSpeed = 16
							Humanoid.JumpPower = 50
							Humanoid.AutoRotate = true
							v.Parent.Humanoid:TakeDamage(25)
							local vel = Instance.new("BodyVelocity", v.Parent.Torso)
							vel.MaxForce = Vector3.new(1,1,1) * 1000000;
							vel.Parent = v.Parent.Torso
							vel.Velocity = Vector3.new(1,1,1) * p.Character:WaitForChild("HumanoidRootPart").CFrame.RightVector * 70
							vel.Name  =  "SmallMoveVel"
							game.Debris:AddItem(vel,.2)
							RagodllModule.RagDoll(v.Parent,1)
							local HitFX = Assets.Headbutt.Attachment:Clone()
							local Head = v.Parent.Head
							HitFX.Parent = Head
							HitFX.Hit2:Play()
							for _,Particles in pairs(HitFX:GetDescendants()) do
								if Particles:IsA("ParticleEmitter") then
									Particles:Emit(Particles:GetAttribute("EmitCount"))
								end
							end
							for _,Particles in pairs(dust:GetDescendants()) do
								if Particles:IsA("ParticleEmitter") then
									Particles:Emit(Particles:GetAttribute("EmitCount"))
								end
							end
							game.Debris:AddItem(HitFX,3)
							local HitFX2 = Assets.HitFXbd.Attach2:Clone()
							HitFX2.Parent = v.Parent.Torso
							for _,Particles in pairs(HitFX2:GetDescendants()) do
								if Particles:IsA("ParticleEmitter") then
									Particles:Emit(Particles:GetAttribute("EmitCount"))
								end
							end
							game.Debris:AddItem(HitFX2,3)
							wait(0.01)
						end
					end
				end
			end
		end
	end
	RootPart.Anchored = false
	Humanoid.WalkSpeed = 16
	Humanoid.JumpPower = 50
	Humanoid.AutoRotate = true
	wait(2)
	FX:Destroy()
	dust:Destroy()
end)