sp=script.Parent damage=0 damagewindow=1 swingrate=.65 clashsounds={91154405,91154446,91154471;91154503;91154521}swooshsounds={89357340,89357340}hitsounds={91154909;91154932,91154954}anims={"\083\116\097\098\049";"\083\116\097\098\050";"\076\101\102\116\083\108\097\115\104"}ready=false equipped=false rate=.033333333333333 lastswing=0 function waitfor(G,M)while G:FindFirstChild(M)==nil do G.ChildAdded:wait()end return G:FindFirstChild(M)end reloading=waitfor(sp,"\082\101\108\111\097\100\105\110\103")down=waitfor(sp,"\077\111\117\115\101\068\111\119\110")runanim=waitfor(sp,"\082\117\110\065\110\105\109")sparkles=waitfor(sp.Handle,"\083\112\097\114\107\108\101\115")debris=game:getService("\068\101\098\114\105\115")weaponhud=waitfor(sp,"\087\101\097\112\111\110\072\117\100")weaponnametag=waitfor(weaponhud,"\087\101\097\112\111\110\078\097\109\101")guibar=waitfor(weaponhud,"\066\097\114")guibarfill=waitfor(guibar,"\070\105\108\108")weaponnametag.Text=sp.Name function runsound(G,M)local t=M or 1 local m=Instance.new("\083\111\117\110\100")m.Looped=false m.Pitch=1 m.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(G)m.PlayOnRemove=false m.Volume=t debris:AddItem(m,3)m.Parent=sp.Handle wait()m:Play()end function billboard(G,M,t,m)local D=G or Vector3.new(0,0,0)local n=M or"\072\101\108\108\111 \087\111\114\108\100\033"local E=t or 2 local P=m or Color3.new(1,0,0)local q=D+Vector3.new(0,5,0)local c=Instance.new("\080\097\114\116")c.Name="\069\102\102\101\099\116"c.formFactor="\067\117\115\116\111\109"c.Size=Vector3.new(0,0,0)c.TopSurface="\083\109\111\111\116\104"c.BottomSurface="\083\109\111\111\116\104"c.CFrame=CFrame.new(q)c.Anchored=true c.CanCollide=false c.Transparency=1 local x=Instance.new("\066\105\108\108\098\111\097\114\100\071\117\105")x.Size=UDim2.new(3,0,3,0)x.Adornee=c local F=Instance.new("\084\101\120\116\076\097\098\101\108")F.BackgroundTransparency=1 F.Size=UDim2.new(0,0,0,0)F.Text=n F.TextColor3=P F.TextScaled=true F.Font="\065\114\105\097\108\066\111\108\100"F.Parent=x x.Parent=c debris:AddItem(c,E+.1)c.Parent=game.Workspace delay(0,function()local G=E/rate for M=1,G,1 do wait(rate)local t=M/G c.CFrame=CFrame.new(q)+Vector3.new(0,5*t,0)F.TextTransparency=t end c:remove()end)end function makeblood(G) end sp.Handle.Touched:connect(function(G)if ready and(equipped and(G and(G.Parent~=nil and(G:IsDescendantOf(sp.Parent)==false and(string.lower(string.sub(G.Name,1,6))~="\101\102\102\101\099\116"and tick()-lastswing<=damagewindow)))))then if G: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)])sparkles.Enabled=true delay(.2,function()sparkles.Enabled=false end)billboard(sp.Handle.Position,"\066\108\111\099\107",2,Color3.new(1,1,0))end local M=sp.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")local t=G.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")local m=sp.Parent:FindFirstChild("\082\105\103\104\116 \065\114\109")local D=game.Players:GetPlayerFromCharacter(sp.Parent)if M and(t and(t~=M and(M.Health>0 and(t.Health>0 and(m and D~=nil)))))then if not D.Neutral then local G=game.Players:GetPlayerFromCharacter(t.Parent)if G~=nil and(G.Neutral==false and G.TeamColor==D.TeamColor)then return end end ready=false for G,M in ipairs(t:GetChildren())do if M.Name=="\099\114\101\097\116\111\114"then M:remove()end end local M=Instance.new("\079\098\106\101\099\116\086\097\108\117\101")M.Name="\099\114\101\097\116\111\114"M.Value=D M.Parent=t debris:AddItem(M,1)local m=math.floor(damage*(.9+math.random()*.2))t:TakeDamage(m)billboard(G.Position,"-"..tostring(m))runsound(hitsounds[math.random(1,#hitsounds)])local n=math.ceil(m/10)for M=1,math.random(n-1,n+1),1 do makeblood(G)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()updategui()wait(swingrate)reloading.Value=false if down.Value then Activate()end end end down.Changed:connect(function()if down.Value then Activate()end end)function updategui()local G=math.min((tick()-lastswing)/swingrate,1)if G<.5 then guibarfill.BackgroundColor3=Color3.new(1,G*2,0)else guibarfill.BackgroundColor3=Color3.new(1-(G-.5)/.5,1,0)end guibarfill.Size=UDim2.new(G,0,1,0)end sp.Equipped:connect(function(G)lastswing=tick()updategui()reloading.Value=true ready=false equipped=true delay(0,function()local G=game.Players:GetPlayerFromCharacter(sp.Parent)if G~=nil then local M=G:FindFirstChild("\080\108\097\121\101\114\071\117\105")if M~=nil and weaponhud~=nil then weaponhud.Parent=M while equipped do updategui()wait(rate)end end end end)wait(swingrate)reloading.Value=false if down.Value then Activate()end end)sp.Unequipped:connect(function()ready=false equipped=false delay(0,function()weaponhud.Parent=sp end)end)
--Made by Stickmasterluke

sp = script.Parent

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

clashsounds = { 91154405, 91154446, 91154471, 91154503, 91154521 }
swooshsounds = { 89357340, 89357340 }
hitsounds = { 91154909, 91154932, 91154954 }
anims = { "Stab1", "Stab2", "LeftSlash" }

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

function waitfor(a, b)
	while a:FindFirstChild(b) == nil do
		a.ChildAdded:wait()
	end
	return a:FindFirstChild(b)
end

reloading = waitfor(sp, "Reloading")
down = waitfor(sp, "MouseDown")
runanim = waitfor(sp, "RunAnim")
sparkles = waitfor(sp.Handle, "Sparkles")
debris = game:getService("Debris")
weaponhud = waitfor(sp, "WeaponHud")
weaponnametag = waitfor(weaponhud, "WeaponName")
guibar = waitfor(weaponhud, "Bar")
guibarfill = waitfor(guibar, "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(0, 0, 0, 0)
	tl.Text = text
	tl.TextColor3 = color
	tl.TextScaled = true
	tl.Font = "ArialBold"

	tl.Parent = bb
	bb.Parent = ep
	debris:AddItem(ep, time + 0.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(0.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
			if not plr.Neutral then
				local eplr = game.Players:GetPlayerFromCharacter(eh.Parent)
				if eplr ~= nil and eplr.Neutral == false and eplr.TeamColor == plr.TeamColor then
					return --No team killing
				end
			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 * (0.9 + (math.random() * 0.2)))
			eh:TakeDamage(localdamage)
			billboard(hit.Position, "-" .. tostring(localdamage))
			runsound(hitsounds[math.random(1, #hitsounds)])
			local bloodeffects = math.ceil(localdamage / 10)
			for i = 1, math.random(bloodeffects - 1, bloodeffects + 1) do
				--[[if math.random()<.5 then
					makeblood(sp.Handle)
				else]]
				makeblood(hit)
				--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)], 0.5)

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

		lastswing = tick()
		updategui()

		wait(swingrate)

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

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

function updategui()
	local swingpercent = math.min((tick() - lastswing) / swingrate, 1)
	if swingpercent < 0.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 - 0.5) / 0.5), 1, 0)
	end
	guibarfill.Size = UDim2.new(swingpercent, 0, 1, 0)
end

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

	reloading.Value = true
	ready = false
	equipped = true

	delay(0, function() --HAAB (Hacking around a bug)
		local plr = game.Players:GetPlayerFromCharacter(sp.Parent)
		if plr ~= nil then
			local plrgui = plr:FindFirstChild("PlayerGui")
			if plrgui ~= nil and weaponhud ~= nil then
				weaponhud.Parent = plrgui
				while equipped do
					updategui()
					wait(rate)
				end
			end
		end
	end)

	wait(swingrate)

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

sp.Unequipped:connect(function()
	ready = false
	equipped = false
	delay(0, function() --HAAB
		weaponhud.Parent = sp
	end)
end)
