r=game:service("\082\117\110\083\101\114\118\105\099\101")function candamage(m,M)if m~=M or m==black and M==black then return true else return false end end local m={"\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(M)for m,C in pairs(m)do if M==C then return true end end return false end local M=5 local C=10 local e=20 sword=script.Parent.Handle Tool=script.Parent local c=sword.SlashSound local l=sword.LungeSound local w=sword.UnsheathSound function blow(m)if m.Parent==nil then return end if matches(m.Name)then local C=m.Parent:findFirstChild("\072\117\109\097\110\111\105\100")local r=Tool.Parent local e=game.Players:playerFromCharacter(r)local c=r:findFirstChild("\072\117\109\097\110\111\105\100")if C and(C~=c and c)then local c=game.Players:GetPlayerFromCharacter(m.Parent)local l=r:FindFirstChild("\082\105\103\104\116 \065\114\109")if l then local m=l:FindFirstChild("\082\105\103\104\116\071\114\105\112")if m and(m.Part0==sword or m.Part1==sword)then if c then if candamage(e.TeamColor,c.TeamColor)==true then tagHumanoid(C,e)C:TakeDamage(M)wait(1)untagHumanoid(C)end else tagHumanoid(C,e)C:TakeDamage(M)wait(1)untagHumanoid(C)end end end end end end function tagHumanoid(m,M)local C=Instance.new("\079\098\106\101\099\116\086\097\108\117\101")C.Value=M C.Name="\099\114\101\097\116\111\114"C.Parent=m end function untagHumanoid(m)if m~=nil then local M=m:findFirstChild("\099\114\101\097\116\111\114")if M~=nil then M.Parent=nil end end end function attack()M=C c:play()local m=Instance.new("\083\116\114\105\110\103\086\097\108\117\101")m.Name="\116\111\111\108\097\110\105\109"m.Value="\083\108\097\115\104"m.Parent=Tool end function lunge()M=e l:play()local m=Instance.new("\083\116\114\105\110\103\086\097\108\117\101")m.Name="\116\111\111\108\097\110\105\109"m.Value="\076\117\110\103\101"m.Parent=Tool wait(.1)swordOut()wait(.75)swordUp()M=C 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 D=0 function onActivated()if not Tool.Enabled then return end Tool.Enabled=false local m=Tool.Parent local M=m.Humanoid if M==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-D<.2 then lunge()else attack()end D=t Tool.Enabled=true end function onEquipped()w: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 = 10
local lunge_damage = 20

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)
