function checkTeams(g)return not(sameTeam(g)and not FriendlyFire)end function onHandleTouched(g)if not AttackDamaging then return end if g:IsDescendantOf(Tool.Parent)then return end if g.Parent and g.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")then local p=g.Parent.Humanoid if checkTeams(p)and not contains(AttackVictims,p)then tagHuman(p)table.insert(AttackVictims,p)p:TakeDamage(AttackDamage)end end end function onProjectileTouched(g)if g:IsDescendantOf(Tool.Parent)then return end if g.Parent and g.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")then local p=g.Parent.Humanoid if checkTeams(p)and not contains(AttackProjectileVictims,p)then tagHuman(p)table.insert(AttackProjectileVictims,p)p:TakeDamage(AttackDamage)end end end function onLeftHold()Remote:FireClient(getPlayer(),"\080\108\097\121\065\110\105\109\097\116\105\111\110","\083\119\105\110\103\050")delay(.1,function()Handle.Swing.Pitch=.8 Handle.Swing:Play()delay(.4,function()Handle.Swing.Pitch=1 Handle.Swing:Play()delay(.3,function()Handle.Swing.Pitch=1.2 Handle.Swing:Play()Handle.Shot.Pitch=math.random(90,110)/100 Handle.Shot:Play()end)end)end)wait(.8)local g=Tool.Parent:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")if g then local p=Instance.new("\080\097\114\116")p.CanCollide=false p.FormFactor="\067\117\115\116\111\109"p.TopSurface="\083\109\111\111\116\104"p.BottomSurface="\083\109\111\111\116\104"p.BrickColor=BrickColor.new("\076\105\109\101 \103\114\101\101\110")p.Size=Vector3.new(3,.2,3)p.CFrame=(g.CFrame*CFrame.new(0,0,-3))*CFrame.Angles(0,0,math.pi/2)Instance.new("\067\121\108\105\110\100\101\114\077\101\115\104",p)local J=Instance.new("\066\111\100\121\086\101\108\111\099\105\116\121")J.maxForce=Vector3.new(1000000000.0,1000000000.0,1000000000.0)J.velocity=g.CFrame.lookVector*AttackProjectileSpeed J.Parent=p local I=Instance.new("\070\105\114\101")I.Color=p.BrickColor.Color I.SecondaryColor=I.Color I.Parent=p local w=Instance.new("\080\111\105\110\116\076\105\103\104\116")w.Range=16 w.Color=p.BrickColor.Color w.Parent=p p.Parent=workspace;(game:GetService("\068\101\098\114\105\115")):AddItem(p,5)AttackProjectileVictims={}local k=p.Touched:connect(onProjectileTouched)wait(.5)p.Anchored=true p.Transparency=1 k:disconnect()I.Enabled=false w:Destroy()end end function onLeftDown()if not AttackAble then return end AttackAble=false Remote:FireClient(getPlayer(),"\080\108\097\121\065\110\105\109\097\116\105\111\110","\083\119\105\110\103\049")delay(.2,function()Handle.Swing.Pitch=math.random(90,110)/100 Handle.Swing:Play()end)delay(AttackWindupTime,function()AttackVictims={}AttackDamaging=true delay(AttackWindow,function()AttackDamaging=false end)end)LeftDown=true local g=0 while LeftDown do g=g+Heartbeat:wait()if g>AttackHoldTime then onLeftHold()break end end delay(AttackRestTime,function()AttackAble=true end)end function onLeftUp()LeftDown=false end function onRemote(g,p,...)if g~=getPlayer()then return end if p=="\076\101\102\116\068\111\119\110"then onLeftDown(...)elseif p=="\076\101\102\116\085\112"then onLeftUp(...)end end Remote.OnServerEvent:connect(onRemote)Handle.Touched:connect(onHandleTouched)
--use this to determine if you want this human to be harmed or not, returns boolean
function checkTeams(otherHuman)
	return not (sameTeam(otherHuman) and not FriendlyFire)
end

function onHandleTouched(part)
	if not AttackDamaging then
		return
	end
	if part:IsDescendantOf(Tool.Parent) then
		return
	end

	if part.Parent and part.Parent:FindFirstChild("Humanoid") then
		local human = part.Parent.Humanoid
		if checkTeams(human) and not contains(AttackVictims, human) then
			tagHuman(human)
			table.insert(AttackVictims, human)
			human:TakeDamage(AttackDamage)
		end
	end
end

function onProjectileTouched(part)
	if part:IsDescendantOf(Tool.Parent) then
		return
	end

	if part.Parent and part.Parent:FindFirstChild("Humanoid") then
		local human = part.Parent.Humanoid
		if checkTeams(human) and not contains(AttackProjectileVictims, human) then
			tagHuman(human)
			table.insert(AttackProjectileVictims, human)
			human:TakeDamage(AttackDamage)
		end
	end
end

function onLeftHold()
	Remote:FireClient(getPlayer(), "PlayAnimation", "Swing2")

	delay(0.1, function()
		Handle.Swing.Pitch = 0.8
		Handle.Swing:Play()
		delay(0.4, function()
			Handle.Swing.Pitch = 1
			Handle.Swing:Play()
			delay(0.3, function()
				Handle.Swing.Pitch = 1.2
				Handle.Swing:Play()
				Handle.Shot.Pitch = math.random(90, 110) / 100
				Handle.Shot:Play()
			end)
		end)
	end)

	wait(0.8)

	local root = Tool.Parent:FindFirstChild("HumanoidRootPart")
	if root then
		local slash = Instance.new("Part")
		slash.CanCollide = false
		slash.FormFactor = "Custom"
		slash.TopSurface = "Smooth"
		slash.BottomSurface = "Smooth"
		slash.BrickColor = BrickColor.new("Lime green")
		slash.Size = Vector3.new(3, 0.2, 3)
		slash.CFrame = root.CFrame * CFrame.new(0, 0, -3) * CFrame.Angles(0, 0, math.pi / 2)

		Instance.new("CylinderMesh", slash)

		local bv = Instance.new("BodyVelocity")
		bv.maxForce = Vector3.new(1e9, 1e9, 1e9)
		bv.velocity = root.CFrame.lookVector * AttackProjectileSpeed
		bv.Parent = slash

		local spark = Instance.new("Fire")
		spark.Color = slash.BrickColor.Color
		spark.SecondaryColor = spark.Color
		spark.Parent = slash

		local light = Instance.new("PointLight")
		light.Range = 16
		light.Color = slash.BrickColor.Color
		light.Parent = slash

		slash.Parent = workspace
		game:GetService("Debris"):AddItem(slash, 5)

		AttackProjectileVictims = {}
		local c = slash.Touched:connect(onProjectileTouched)

		wait(0.5)
		slash.Anchored = true
		slash.Transparency = 1
		c:disconnect()
		spark.Enabled = false
		light:Destroy()
	end
end

function onLeftDown()
	if not AttackAble then
		return
	end
	AttackAble = false

	Remote:FireClient(getPlayer(), "PlayAnimation", "Swing1")

	delay(0.2, function()
		Handle.Swing.Pitch = math.random(90, 110) / 100
		Handle.Swing:Play()
	end)

	delay(AttackWindupTime, function()
		AttackVictims = {}
		AttackDamaging = true
		delay(AttackWindow, function()
			AttackDamaging = false
		end)
	end)

	LeftDown = true
	local t = 0
	while LeftDown do
		t = t + Heartbeat:wait()
		if t > AttackHoldTime then
			onLeftHold()
			break
		end
	end

	delay(AttackRestTime, function()
		AttackAble = true
	end)
end

function onLeftUp()
	LeftDown = false
end

function onRemote(player, func, ...)
	if player ~= getPlayer() then
		return
	end

	if func == "LeftDown" then
		onLeftDown(...)
	elseif func == "LeftUp" then
		onLeftUp(...)
	end
end

Remote.OnServerEvent:connect(onRemote)
Handle.Touched:connect(onHandleTouched)
