r=game:service("\082\117\110\083\101\114\118\105\099\101")function candamage(v,f)if v~=f or v==black and f==black then return true else return false end end local v={"\072\101\097\100","\076\101\102\116 \065\114\109";"\076\101\102\116 \076\101\103","\082\105\103\104\116 \065\114\109";"\082\105\103\104\116 \076\101\103","\084\111\114\115\111"}function matches(f)for v,N in pairs(v)do if f==N then return true end end return false end local f=5 local N=9 local D=18 sword=script.Parent.Handle Tool=script.Parent local i=sword.SlashSound local u=sword.LungeSound local V=sword.UnsheathSound function blow(v)if v.Parent==nil then return end if matches(v.Name)then local N=v.Parent:findFirstChild("\072\117\109\097\110\111\105\100")local D=Tool.Parent local i=game.Players:playerFromCharacter(D)local u=D:findFirstChild("\072\117\109\097\110\111\105\100")if N and(N~=u and u)then local u=game.Players:GetPlayerFromCharacter(v.Parent)local V=D:FindFirstChild("\082\105\103\104\116 \065\114\109")if V then local v=V:FindFirstChild("\082\105\103\104\116\071\114\105\112")if v and(v.Part0==sword or v.Part1==sword)then if u then if candamage(i.TeamColor,u.TeamColor)==true then tagHumanoid(N,i)N:TakeDamage(f)wait(1)untagHumanoid(N)end else tagHumanoid(N,i)N:TakeDamage(f)wait(1)untagHumanoid(N)end end end end end end function tagHumanoid(v,f)local N=Instance.new("\079\098\106\101\099\116\086\097\108\117\101")N.Value=f N.Name="\099\114\101\097\116\111\114"N.Parent=v end function untagHumanoid(v)if v~=nil then local f=v:findFirstChild("\099\114\101\097\116\111\114")if f~=nil then f.Parent=nil end end end function attack()f=N i:play()local v=Instance.new("\083\116\114\105\110\103\086\097\108\117\101")v.Name="\116\111\111\108\097\110\105\109"v.Value="\083\108\097\115\104"v.Parent=Tool end function lunge()f=D u:play()local v=Instance.new("\083\116\114\105\110\103\086\097\108\117\101")v.Name="\116\111\111\108\097\110\105\109"v.Value="\076\117\110\103\101"v.Parent=Tool wait(.1)swordOut()wait(.75)swordUp()f=N end function swordUp()Tool.GripForward=Vector3.new(-1,0,0)Tool.GripRight=Vector3.new(0,1,0)Tool.GripUp=Vector3.new(0,0,1)end function swordOut()Tool.GripForward=Vector3.new(0,0,1)Tool.GripRight=Vector3.new(0,-1,0)Tool.GripUp=Vector3.new(-1,0,0)end function swordAcross() end Tool.Enabled=true local J=0 function onActivated()if not Tool.Enabled then return end Tool.Enabled=false local v=Tool.Parent local f=v.Humanoid if f==nil then print("\072\117\109\097\110\111\105\100 \110\111\116 \102\111\117\110\100")return end t=r.Stepped:wait()if t-J<.2 then lunge()else attack()end J=t Tool.Enabled=true end function onEquipped()V:play()end script.Parent.Activated:connect(onActivated)script.Parent.Equipped:connect(onEquipped)connection=sword.Touched:connect(blow)
--END OF CONFIGURABLE OPTIONS--

r = game:service("RunService")

function candamage(myteam, theirteam)
	if myteam ~= theirteam or (myteam == black and theirteam == black) then
		return true
	else
		return false
	end
end

local acceptableparts = {
	"Head",
	"Left Arm",
	"Left Leg",
	"Right Arm",
	"Right Leg",
	"Torso",
}

function matches(partname)
	for i, v in pairs(acceptableparts) do
		if partname == v then
			return true
		end
	end
	return false
end

local damage = 5
local slash_damage = 9
local lunge_damage = 18

sword = script.Parent.Handle
Tool = script.Parent

local SlashSound = sword.SlashSound

local LungeSound = sword.LungeSound

local UnsheathSound = sword.UnsheathSound

function blow(hit)
	if hit.Parent == nil then
		return
	end

	if matches(hit.Name) then
		local humanoid = hit.Parent:findFirstChild("Humanoid")
		local vCharacter = Tool.Parent
		local vPlayer = game.Players:playerFromCharacter(vCharacter)
		local hum = vCharacter:findFirstChild("Humanoid")
		if humanoid and humanoid ~= hum and hum then
			-- final check, make sure sword is in-hand
			local guygettingsliced = game.Players:GetPlayerFromCharacter(hit.Parent) --OH LOOK, here's an edit
			local right_arm = vCharacter:FindFirstChild("Right Arm")
			if right_arm then
				local joint = right_arm:FindFirstChild("RightGrip")
				if joint and (joint.Part0 == sword or joint.Part1 == sword) then
					if guygettingsliced then --If he's a player
						if candamage(vPlayer.TeamColor, guygettingsliced.TeamColor) == true then
							tagHumanoid(humanoid, vPlayer)
							humanoid:TakeDamage(damage)
							wait(1)
							untagHumanoid(humanoid)
						end
					else --If he's not a player (AI, shop, etc)
						tagHumanoid(humanoid, vPlayer)
						humanoid:TakeDamage(damage)
						wait(1)
						untagHumanoid(humanoid)
					end
				end
			end
		end
	end
end

function tagHumanoid(humanoid, player)
	local creator_tag = Instance.new("ObjectValue")
	creator_tag.Value = player
	creator_tag.Name = "creator"
	creator_tag.Parent = humanoid
end

function untagHumanoid(humanoid)
	if humanoid ~= nil then
		local tag = humanoid:findFirstChild("creator")
		if tag ~= nil then
			tag.Parent = nil
		end
	end
end

function attack()
	damage = slash_damage
	SlashSound:play()
	local anim = Instance.new("StringValue")
	anim.Name = "toolanim"
	anim.Value = "Slash"
	anim.Parent = Tool
end

function lunge()
	damage = lunge_damage

	LungeSound:play()

	local anim = Instance.new("StringValue")
	anim.Name = "toolanim"
	anim.Value = "Lunge"
	anim.Parent = Tool

	wait(0.1)
	swordOut()
	wait(0.75)
	swordUp()

	damage = slash_damage
end

function swordUp()
	Tool.GripForward = Vector3.new(-1, 0, 0)
	Tool.GripRight = Vector3.new(0, 1, 0)
	Tool.GripUp = Vector3.new(0, 0, 1)
end

function swordOut()
	Tool.GripForward = Vector3.new(0, 0, 1)
	Tool.GripRight = Vector3.new(0, -1, 0)
	Tool.GripUp = Vector3.new(-1, 0, 0)
end

function swordAcross()
	-- parry
end

Tool.Enabled = true
local last_attack = 0
function onActivated()
	if not Tool.Enabled then
		return
	end

	Tool.Enabled = false

	local character = Tool.Parent
	local humanoid = character.Humanoid
	if humanoid == nil then
		print("Humanoid not found")
		return
	end

	t = r.Stepped:wait()

	if t - last_attack < 0.2 then
		lunge()
	else
		attack()
	end

	last_attack = t

	--wait(.5)

	Tool.Enabled = true
end

function onEquipped()
	UnsheathSound:play()
end

script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)

connection = sword.Touched:connect(blow)
