sp=script.Parent damage=100 damagewindow=1 swingrate=.75 clashsounds={91154405,91154446;91154471,91154503,91154521}swooshsounds={91154708,91155889}hitsounds={91154909;91154932;91154954}anims={"\083\116\097\098\049","\083\116\097\098\050","\082\105\103\104\116\083\108\097\115\104";"\076\101\102\116\083\108\097\115\104"}bloodeffects=false ready=false equipped=false rate=.033333333333333 lastswing=0 local y=sp:WaitForChild("\082\101\108\111\097\100\105\110\103")local P=sp:WaitForChild("\077\111\117\115\101\068\111\119\110")local X=sp:WaitForChild("\082\117\110\065\110\105\109")local C=sp.Handle:WaitForChild("\083\112\097\114\107\108\101\115")local D=game:getService("\068\101\098\114\105\115")local U=sp:WaitForChild("\087\101\097\112\111\110\072\117\100")local m=U:WaitForChild("\087\101\097\112\111\110\078\097\109\101")local A=U:WaitForChild("\066\097\114")local c=A:WaitForChild("\070\105\108\108")m.Text=sp.Name function runsound(y,P)local X=P or 1 local C=Instance.new("\083\111\117\110\100")C.Looped=false C.Pitch=1 C.SoundId="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061"..tostring(y)C.PlayOnRemove=false C.Volume=X D:AddItem(C,3)C.Parent=sp.Handle wait()C:Play()end function billboard(y,P,X,C)local U=y or Vector3.new(0,0,0)local m=P or"\072\101\108\108\111 \087\111\114\108\100\033"local A=X or 2 local c=C or Color3.new(1,0,0)local V=U+Vector3.new(0,5,0)local q=Instance.new("\080\097\114\116")q.Name="\069\102\102\101\099\116"q.formFactor="\067\117\115\116\111\109"q.Size=Vector3.new(0,0,0)q.TopSurface="\083\109\111\111\116\104"q.BottomSurface="\083\109\111\111\116\104"q.CFrame=CFrame.new(V)q.Anchored=true q.CanCollide=false q.Transparency=1 local L=Instance.new("\066\105\108\108\098\111\097\114\100\071\117\105")L.Size=UDim2.new(3,0,3,0)L.Adornee=q local N=Instance.new("\084\101\120\116\076\097\098\101\108")N.BackgroundTransparency=1 N.Size=UDim2.new(1,0,1,0)N.Text=m N.TextColor3=c N.TextScaled=true N.Font="\065\114\105\097\108\066\111\108\100"N.Parent=L L.Parent=q D:AddItem(q,A+.1)q.Parent=game.Workspace delay(0,function()local y=A/rate for P=1,y,1 do wait(rate)local X=P/y q.CFrame=CFrame.new(V)+Vector3.new(0,5*X,0)N.TextTransparency=X end q:remove()end)end function makeblood(y)if y then local P=Instance.new("\080\097\114\116")P.BrickColor=BrickColor.new("\066\114\105\103\104\116 \114\101\100")P.formFactor="\067\117\115\116\111\109"P.Transparency=math.random(0,1)*.5 if math.random()<.5 then P.CanCollide=false else P.CanCollide=true end P.TopSurface="\083\109\111\111\116\104"P.BottomSurface="\083\109\111\111\116\104"P.Size=Vector3.new(.2*math.random(1,5),.2*math.random(1,5),.2*math.random(1,5))P.Velocity=y.Velocity+Vector3.new(math.random()-.5,math.random()-.5,math.random()-.5)*30 P.RotVelocity=y.RotVelocity+Vector3.new(math.random()-.5,math.random()-.5,math.random()-.5)*20 P.CFrame=(y.CFrame*CFrame.new((math.random()-.5)*3,(math.random()-.5)*3,(math.random()-.5)*3))*CFrame.Angles((math.pi*2)*math.random(),(math.pi*2)*math.random(),(math.pi*2)*math.random())D:AddItem(P,math.random()*4)P.Parent=game.Workspace end end sp.Handle.Touched:connect(function(y)if ready and(equipped and(y and(y.Parent~=nil and(y:IsDescendantOf(sp.Parent)==false and(string.lower(string.sub(y.Name,1,6))~="\101\102\102\101\099\116"and tick()-lastswing<=damagewindow)))))then if y:FindFirstChild("\067\097\110\066\108\111\099\107")and sp.Handle:FindFirstChild("\066\108\111\099\107\097\098\108\101")then ready=false runsound(clashsounds[math.random(1,#clashsounds)])C.Enabled=true delay(.2,function()C.Enabled=false end)billboard(sp.Handle.Position,"\066\108\111\099\107",2,Color3.new(1,1,0))end local P=sp.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")local X=y.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")local U=sp.Parent:FindFirstChild("\082\105\103\104\116 \065\114\109")local m=game.Players:GetPlayerFromCharacter(sp.Parent)if P and(X and(X~=P and(P.Health>0 and(X.Health>0 and(U and m~=nil)))))then local P=game.Players:GetPlayerFromCharacter(X.Parent)if P~=nil and(not P.Neutral and(not m.Neutral and P.TeamColor==m.TeamColor))then return end ready=false for y,P in ipairs(X:GetChildren())do if P.Name=="\099\114\101\097\116\111\114"then P:remove()end end local C=Instance.new("\079\098\106\101\099\116\086\097\108\117\101")C.Name="\099\114\101\097\116\111\114"C.Value=m C.Parent=X D:AddItem(C,1)local U=math.floor(damage*(.9+math.random()*.2)+.5)X:TakeDamage(U)billboard(y.Position,"-"..tostring(U))runsound(hitsounds[math.random(1,#hitsounds)])if bloodeffects then local P=math.ceil(U/10)for P=1,math.random(P-1,P+1),1 do makeblood(y)end end end end end)function Activate()if equipped and tick()-lastswing>=swingrate then ready=true y.Value=true runsound(swooshsounds[math.random(1,#swooshsounds)],.5)newanim=anims[math.random(1,#anims)]while newanim==X.Value do newanim=anims[math.random(1,#anims)]end X.Value=newanim lastswing=tick()wait(swingrate)y.Value=false if P.Value then Activate()end end end P.Changed:connect(function()if P.Value then Activate()end end)sp.Equipped:connect(function(X)lastswing=tick()y.Value=true ready=false equipped=true local C=game.Players:GetPlayerFromCharacter(sp.Parent)if C~=nil then local y=C:FindFirstChild("\080\108\097\121\101\114\071\117\105")if y~=nil then U.Parent=y end end wait(swingrate)y.Value=false if P.Value then Activate()end end)sp.Unequipped:connect(function()ready=false equipped=false U.Parent=sp end)function updategui()local y=math.min((tick()-lastswing)/swingrate,1)if y<.5 then c.BackgroundColor3=Color3.new(1,y*2,0)else c.BackgroundColor3=Color3.new(1-(y-.5)/.5,1,0)end c.Size=UDim2.new(y,0,1,0)end while true do updategui()wait(rate)end



sp=script.Parent


damage=100						--  +/- 10%
damagewindow=1					--after clicking, how long does the player have to hit the opponent wioth their weapon to deal damage
swingrate=.75

clashsounds={91154405,91154446,91154471,91154503,91154521}
swooshsounds={91154708,91155889}
hitsounds={91154909,91154932,91154954}
anims={"Stab1","Stab2","RightSlash","LeftSlash"}
bloodeffects=false


ready=false
equipped=false
rate=1/30
lastswing=0


local reloading=sp:WaitForChild("Reloading")
local down=sp:WaitForChild("MouseDown")
local runanim=sp:WaitForChild("RunAnim")
local sparkles=sp.Handle:WaitForChild("Sparkles")
local debris=game:getService("Debris")
local weaponhud=sp:WaitForChild("WeaponHud")
local weaponnametag=weaponhud:WaitForChild("WeaponName")
local guibar=weaponhud:WaitForChild("Bar")
local guibarfill=guibar:WaitForChild("Fill")
weaponnametag.Text=sp.Name

function runsound(id,volume)
	local volume=volume or 1
	local sound=Instance.new("Sound")
	sound.Looped=false
	sound.Pitch=1
	sound.SoundId="http://www.roblox.com/asset/?id="..tostring(id)
	sound.PlayOnRemove=false
	sound.Volume=volume
	debris:AddItem(sound,3)
	sound.Parent=sp.Handle
	wait()
	sound:Play()
end

function billboard(pos,text,time,color)
	local pos=pos or Vector3.new(0,0,0)
	local text=text or "Hello World!"
	local time=time or 2
	local color=color or Color3.new(1,0,0)
	local pos=pos+Vector3.new(0,5,0)
	local ep=Instance.new("Part")
	ep.Name="Effect"
	ep.formFactor="Custom"
	ep.Size=Vector3.new(0,0,0)
	ep.TopSurface="Smooth"
	ep.BottomSurface="Smooth"
	ep.CFrame=CFrame.new(pos)
	ep.Anchored=true
	ep.CanCollide=false
	ep.Transparency=1
	local bb=Instance.new("BillboardGui")
	bb.Size=UDim2.new(3,0,3,0)
	bb.Adornee=ep
	local tl=Instance.new("TextLabel")
	tl.BackgroundTransparency=1
	tl.Size=UDim2.new(1,0,1,0)
	tl.Text=text
	tl.TextColor3=color
	tl.TextScaled=true
	tl.Font="ArialBold"

	tl.Parent=bb
	bb.Parent=ep
	debris:AddItem(ep,time+.1)
	ep.Parent=game.Workspace
	delay(0,function()
		local frames=time/rate
		for frame=1,frames do
			wait(rate)
			local percent=frame/frames
			ep.CFrame=CFrame.new(pos)+Vector3.new(0,5*percent,0)
			tl.TextTransparency=percent
		end
		ep:remove()
	end)
end

function makeblood(part)
	if part then
		local b=Instance.new("Part")
		b.BrickColor=BrickColor.new("Bright red")
		b.formFactor="Custom"
		b.Transparency=math.random(0,1)*.5
		if math.random()<.5 then
			b.CanCollide=false
		else
			b.CanCollide=true
		end
		b.TopSurface="Smooth"
		b.BottomSurface="Smooth"
		b.Size=Vector3.new(.2*math.random(1,5),.2*math.random(1,5),.2*math.random(1,5))
		b.Velocity=part.Velocity+(Vector3.new((math.random()-.5),(math.random()-.5),(math.random()-.5))*30)
		b.RotVelocity=part.RotVelocity+(Vector3.new((math.random()-.5),(math.random()-.5),(math.random()-.5))*20)
		b.CFrame=part.CFrame*CFrame.new((math.random()-.5)*3,(math.random()-.5)*3,(math.random()-.5)*3)*CFrame.Angles(math.pi*2*math.random(),math.pi*2*math.random(),math.pi*2*math.random())
		debris:AddItem(b,math.random()*4)
		b.Parent=game.Workspace
	end
end

sp.Handle.Touched:connect(function(hit)
	if ready and equipped and hit and hit.Parent~=nil and hit:IsDescendantOf(sp.Parent)==false and string.lower(string.sub(hit.Name,1,6))~="effect" and (tick()-lastswing)<=damagewindow then
		if hit:FindFirstChild("CanBlock") and sp.Handle:FindFirstChild("Blockable") then
			ready=false
			runsound(clashsounds[math.random(1,#clashsounds)])
			sparkles.Enabled=true
			delay(.2,function()
				sparkles.Enabled=false
			end)
			billboard(sp.Handle.Position,"Block",2,Color3.new(1,1,0))
		end
		local mh=sp.Parent:FindFirstChild("Humanoid")
		local eh=hit.Parent:FindFirstChild("Humanoid")
		local ra=sp.Parent:FindFirstChild("Right Arm")
		local plr=game.Players:GetPlayerFromCharacter(sp.Parent)
		if mh and eh and eh~=mh and mh.Health>0 and eh.Health>0 and ra and plr~=nil then
			local eplr=game.Players:GetPlayerFromCharacter(eh.Parent)
			if eplr~=nil and not eplr.Neutral and not plr.Neutral and eplr.TeamColor==plr.TeamColor then
				return	--No team killing
			end
			ready=false
			for i,v in ipairs(eh:GetChildren()) do
				if v.Name=="creator" then
					v:remove()
				end
			end
			local creator=Instance.new("ObjectValue")
			creator.Name="creator"
			creator.Value=plr
			creator.Parent=eh
			debris:AddItem(creator,1)
			local localdamage=math.floor(damage*(.9+(math.random()*.2))+.5)
			eh:TakeDamage(localdamage)
			billboard(hit.Position,"-"..tostring(localdamage))
			runsound(hitsounds[math.random(1,#hitsounds)])
			if bloodeffects then
				local numbloodeffects=math.ceil(localdamage/10)
				for i=1,math.random(numbloodeffects-1,numbloodeffects+1) do
					--[[if math.random()<.5 then
						makeblood(sp.Handle)
					else]]
						makeblood(hit)
					--end
				end
			end
		end
	end
end)


function Activate()
	if equipped and (tick()-lastswing)>=swingrate then
		ready=true
		reloading.Value=true

		runsound(swooshsounds[math.random(1,#swooshsounds)],.5)

		newanim=anims[math.random(1,#anims)]
		while newanim==runanim.Value do
			newanim=anims[math.random(1,#anims)]
		end
		runanim.Value=newanim

		lastswing=tick()

		wait(swingrate)

		reloading.Value=false
		if down.Value then
			Activate()
		end
	end
end

down.Changed:connect(function()
	if down.Value then
		Activate()
	end
end)

sp.Equipped:connect(function(mouse)
	lastswing=tick()

	reloading.Value=true
	ready=false
	equipped=true
	local plr=game.Players:GetPlayerFromCharacter(sp.Parent)
	if plr~=nil then
		local plrgui=plr:FindFirstChild("PlayerGui")
		if plrgui~=nil then
			weaponhud.Parent=plrgui
		end
	end

	wait(swingrate)

	reloading.Value=false
	if down.Value then
		Activate()
	end
end)

sp.Unequipped:connect(function()
	ready=false
	equipped=false
	weaponhud.Parent=sp
end)


function updategui()
	local swingpercent=math.min((tick()-lastswing)/swingrate,1)
	if swingpercent<.5 then	--fade from red to yellow then to green
		guibarfill.BackgroundColor3=Color3.new(1,swingpercent*2,0)
	else
		guibarfill.BackgroundColor3=Color3.new(1-((swingpercent-.5)/.5),1,0)
	end
	guibarfill.Size=UDim2.new(swingpercent,0,1,0)
end
while true do
	updategui()
	wait(rate)
end






