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


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 = 11
local lunge_damage = 22

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(.1)
	swordOut()
	wait(.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 < .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)


