Tool=script.Parent Handle=Tool:WaitForChild("\072\097\110\100\108\101")Sparkles=Handle:WaitForChild("\083\112\097\114\107\108\101\115")Players=game:GetService("\080\108\097\121\101\114\115")Debris=game:GetService("\068\101\098\114\105\115")WeaponHud=Tool:WaitForChild("\087\101\097\112\111\110\072\117\100")WeaponNameTag=WeaponHud:WaitForChild("\087\101\097\112\111\110\078\097\109\101")GuiBar=WeaponHud:WaitForChild("\066\097\114")GuiBarFill=GuiBar:WaitForChild("\070\105\108\108")WeaponNameTag.Text=(Tool:WaitForChild("\084\111\111\108\078\097\109\101")).Value BasePart=Instance.new("\080\097\114\116")BasePart.Shape=Enum.PartType.Block BasePart.Material=Enum.Material.Plastic BasePart.TopSurface=Enum.SurfaceType.Smooth BasePart.BottomSurface=Enum.SurfaceType.Smooth BasePart.FormFactor=Enum.FormFactor.Custom BasePart.Size=Vector3.new(.2,.2,.2)BasePart.CanCollide=true BasePart.Locked=true BasePart.Anchored=false Animations={Equip={Animation=Tool:WaitForChild("\069\113\117\105\112");FadeTime=nil;Weight=nil;Speed=1.5,Duration=nil},Hold={Animation=Tool:WaitForChild("\072\111\108\100");FadeTime=nil,Weight=nil,Speed=nil;Duration=nil};LeftSlash={Animation=Tool:WaitForChild("\076\101\102\116\083\108\097\115\104"),FadeTime=nil;Weight=nil;Speed=1.2;Duration=nil},RightSlash={Animation=Tool:WaitForChild("\082\105\103\104\116\083\108\097\115\104");FadeTime=nil;Weight=nil,Speed=1.2,Duration=nil},Stab1={Animation=Tool:WaitForChild("\083\116\097\098\049");FadeTime=nil,Weight=nil;Speed=1.2;Duration=nil},Stab2={Animation=Tool:WaitForChild("\083\116\097\098\050");FadeTime=nil,Weight=nil,Speed=1.2;Duration=nil}}Sounds={Swoosh1=Handle:WaitForChild("\083\119\111\111\115\104\049"),Swoosh2=Handle:WaitForChild("\083\119\111\111\115\104\050");Hit1=Handle:WaitForChild("\072\105\116\049"),Hit2=Handle:WaitForChild("\072\105\116\050");Hit3=Handle:WaitForChild("\072\105\116\051");Clash1=Handle:WaitForChild("\067\108\097\115\104\049");Clash2=Handle:WaitForChild("\067\108\097\115\104\050");Clash3=Handle:WaitForChild("\067\108\097\115\104\051");Clash4=Handle:WaitForChild("\067\108\097\115\104\052"),Clash5=Handle:WaitForChild("\067\108\097\115\104\053")}Damage=95 DamageWindow=1 SwingRate=.55 BloodEffects=true Ready=false ToolEquipped=false Rate=.033333333333333 LastSwing=0 MouseDown=false CurrentAnimation=nil ServerControl=Tool:FindFirstChild("\083\101\114\118\101\114\067\111\110\116\114\111\108")or Instance.new("\082\101\109\111\116\101\070\117\110\099\116\105\111\110")ServerControl.Name="\083\101\114\118\101\114\067\111\110\116\114\111\108"ServerControl.Parent=Tool ClientControl=Tool:FindFirstChild("\067\108\105\101\110\116\067\111\110\116\114\111\108")or Instance.new("\082\101\109\111\116\101\070\117\110\099\116\105\111\110")ClientControl.Name="\067\108\105\101\110\116\067\111\110\116\114\111\108"ClientControl.Parent=Tool Tool.Enabled=true ServerControl.OnServerInvoke=function(g,n,D)if g==Player then if n=="\077\111\117\115\101\067\108\105\099\107"then MouseDown=D.Down if MouseDown then Activated()end elseif n=="\075\101\121\080\114\101\115\115"then local g=D.Key local n=D.Down end end end function InvokeClient(g,n)local D=nil pcall(function()D=ClientControl:InvokeClient(Player,g,n)end)return D end function TagHumanoid(g,n)local D=Instance.new("\079\098\106\101\099\116\086\097\108\117\101")D.Name="\099\114\101\097\116\111\114"D.Value=n Debris:AddItem(D,2)D.Parent=g end function UntagHumanoid(g)for g,n in pairs(g:GetChildren())do if n:IsA("\079\098\106\101\099\116\086\097\108\117\101")and n.Name=="\099\114\101\097\116\111\114"then n:Destroy()end end end function Billboard(g,n,D,t)local C=g or Vector3.new(0,0,0)local w=n or"\072\101\108\108\111 \087\111\114\108\100\033"local o=D or 2 local F=t or Color3.new(1,0,0)local y=C+Vector3.new(0,5,0)local c=BasePart:Clone()c.Name="\069\102\102\101\099\116"c.Size=Vector3.new(0,0,0)c.CFrame=CFrame.new(y)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 Y=Instance.new("\084\101\120\116\076\097\098\101\108")Y.BackgroundTransparency=1 Y.Size=UDim2.new(1,0,1,0)Y.Text=w Y.TextColor3=F Y.TextScaled=true Y.Font=Enum.Font.ArialBold Y.Parent=X X.Parent=c Debris:AddItem(c,o+.1)c.Parent=game:GetService("\087\111\114\107\115\112\097\099\101")Delay(0,function()local g=o/Rate for n=1,g,1 do wait(Rate)local D=n/g c.CFrame=CFrame.new(y)+Vector3.new(0,5*D,0)Y.TextTransparency=D end if c and c.Parent then c:Destroy()end end)end function MakeBlood(g)if not g then return end local n=BasePart:Clone()n.BrickColor=BrickColor.new("\066\114\105\103\104\116 \114\101\100")n.Transparency=math.random(0,1)*.5 n.CanCollide=math.random()<.5 and false or true n.Size=Vector3.new(.2*math.random(1,5),.2*math.random(1,5),.2*math.random(1,5))n.Velocity=g.Velocity+Vector3.new(math.random()-.5,math.random()-.5,math.random()-.5)*30 n.RotVelocity=g.RotVelocity+Vector3.new(math.random()-.5,math.random()-.5,math.random()-.5)*20 n.CFrame=(g.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(n,math.random()*4)n.Parent=game:GetService("\087\111\114\107\115\112\097\099\101")end function Blow(g)if not g or not g.Parent or not CheckIfAlive()or not Ready or not ToolEquipped or tick()-LastSwing>DamageWindow then return end local n=g.Parent if n==Character then return end if g:FindFirstChild("\067\097\110\066\108\111\099\107")and Handle:FindFirstChild("\066\108\111\099\107\097\098\108\101")then local g=false local n={Sounds.Clash1;Sounds.Clash2;Sounds.Clash3,Sounds.Clash4;Sounds.Clash5}local D=n[math.random(1,#n)]D:Play()Sparkles.Enabled=true Delay(.2,function()Sparkles.Enabled=false end)Billboard(Handle.Position,"\066\108\111\099\107",2,Color3.new(1,1,0))end local D=n:FindFirstChild("\072\117\109\097\110\111\105\100")local t=Players:GetPlayerFromCharacter(n)local C=Character:FindFirstChild("\082\105\103\104\116 \065\114\109")if D and(D.Health>0 and(D~=Humanoid and C))then local n=C:FindFirstChild("\082\105\103\104\116\071\114\105\112")if n and(n.Part0==Handle or n.Part1==Handle)then if t and(t~=Player and(not Player.Neutral and(not t.Neutral and Player.TeamColor==t.TeamColor)))then return end Ready=false UntagHumanoid(D)TagHumanoid(D)local n=math.floor(Damage*(.9+math.random()*.2)+.5)D:TakeDamage(n)Billboard(g.Position,"-"..tostring(n))local C={Sounds.Hit1,Sounds.Hit2;Sounds.Hit3}local w=C[math.random(1,#C)]w:Play()if BloodEffects then local D=math.ceil(n/10)for n=1,math.random(D-1,D+1),1 do MakeBlood(g)end end end end end function Activated()if ToolEquipped and tick()-LastSwing>=SwingRate then Tool.Enabled=false Ready=true local g={Sounds.Swoosh1,Sounds.Swoosh2}local n=g[math.random(1,#g)]n:Play()local D={Animations.LeftSlash,Animations.RightSlash;Animations.Stab1;Animations.Stab2}local t=D[math.random(1,#D)]while t==CurrentAnimation do t=D[math.random(1,#D)]end CurrentAnimation=t InvokeClient("\080\108\097\121\065\110\105\109\097\116\105\111\110",CurrentAnimation)LastSwing=tick()wait(SwingRate)if MouseDown then Activated()end Tool.Enabled=true 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 function CheckIfAlive()return Player and(Player.Parent and(Humanoid and(Humanoid.Parent and Humanoid.Health>0)))end function Equipped()Character=Tool.Parent Player=Players:GetPlayerFromCharacter(Character)PlayerGui=Player:FindFirstChild("\080\108\097\121\101\114\071\117\105")Humanoid=Character:FindFirstChild("\072\117\109\097\110\111\105\100")if not CheckIfAlive()then return end if PlayerGui then WeaponHud.Parent=PlayerGui end InvokeClient("\080\108\097\121\065\110\105\109\097\116\105\111\110",Animations.Equip)LastSwing=tick()Ready=false ToolEquipped=true for g,n in pairs(Animations)do if n and n.Animation then InvokeClient("\080\114\101\108\111\097\100",n.Animation.AnimationId)end end ToolEquipped=true end function Unequipped()for g,n in pairs(Animations)do InvokeClient("\083\116\111\112\065\110\105\109\097\116\105\111\110",n)end WeaponHud.Parent=Tool ToolEquipped=false Ready=false end Handle.Touched:connect(Blow)Tool.Equipped:connect(Equipped)Tool.Unequipped:connect(Unequipped)Spawn(function()while true do UpdateGui()wait(Rate)end end)


Tool = script.Parent
Handle = Tool:WaitForChild("Handle")
Sparkles = Handle:WaitForChild("Sparkles")

Players = game:GetService("Players")
Debris = game:GetService("Debris")

WeaponHud = Tool:WaitForChild("WeaponHud")
WeaponNameTag = WeaponHud:WaitForChild("WeaponName")
GuiBar = WeaponHud:WaitForChild("Bar")
GuiBarFill = GuiBar:WaitForChild("Fill")
WeaponNameTag.Text = Tool:WaitForChild("ToolName").Value

BasePart = Instance.new("Part")
BasePart.Shape = Enum.PartType.Block
BasePart.Material = Enum.Material.Plastic
BasePart.TopSurface = Enum.SurfaceType.Smooth
BasePart.BottomSurface = Enum.SurfaceType.Smooth
BasePart.FormFactor = Enum.FormFactor.Custom
BasePart.Size = Vector3.new(0.2, 0.2, 0.2)
BasePart.CanCollide = true
BasePart.Locked = true
BasePart.Anchored = false

Animations = {
	Equip = {Animation = Tool:WaitForChild("Equip"), FadeTime = nil, Weight = nil, Speed = 1.5, Duration = nil},
	Hold = {Animation = Tool:WaitForChild("Hold"), FadeTime = nil, Weight = nil, Speed = nil, Duration = nil},
	LeftSlash = {Animation = Tool:WaitForChild("LeftSlash"), FadeTime = nil, Weight = nil, Speed = 1.2, Duration = nil},
	RightSlash = {Animation = Tool:WaitForChild("RightSlash"), FadeTime = nil, Weight = nil, Speed = 1.2, Duration = nil},
	Stab1 = {Animation = Tool:WaitForChild("Stab1"), FadeTime = nil, Weight = nil, Speed = 1.2, Duration = nil},
	Stab2 = {Animation = Tool:WaitForChild("Stab2"), FadeTime = nil, Weight = nil, Speed = 1.2, Duration = nil},
}

Sounds = {
	Swoosh1 = Handle:WaitForChild("Swoosh1"),
	Swoosh2 = Handle:WaitForChild("Swoosh2"),
	Hit1 = Handle:WaitForChild("Hit1"),
	Hit2 = Handle:WaitForChild("Hit2"),
	Hit3 = Handle:WaitForChild("Hit3"),
	Clash1 = Handle:WaitForChild("Clash1"),
	Clash2 = Handle:WaitForChild("Clash2"),
	Clash3 = Handle:WaitForChild("Clash3"),
	Clash4 = Handle:WaitForChild("Clash4"),
	Clash5 = Handle:WaitForChild("Clash5"),
}

Damage = 95 -- +/- 10%
DamageWindow = 1 --How long the player has to hit opponent to deal damage after click
SwingRate = 0.55

BloodEffects = true

Ready = false
ToolEquipped = false
Rate = (1 / 30)
LastSwing = 0

MouseDown = false
CurrentAnimation = nil

ServerControl = (Tool:FindFirstChild("ServerControl") or Instance.new("RemoteFunction"))
ServerControl.Name = "ServerControl"
ServerControl.Parent = Tool

ClientControl = (Tool:FindFirstChild("ClientControl") or Instance.new("RemoteFunction"))
ClientControl.Name = "ClientControl"
ClientControl.Parent = Tool

Tool.Enabled = true

ServerControl.OnServerInvoke = (function(player, Mode, Value)
	if player == Player then
		if Mode == "MouseClick" then
			MouseDown = Value.Down
			if MouseDown then
				Activated()
			end
		elseif Mode == "KeyPress" then
			local Key = Value.Key
			local Down = Value.Down
		end
	end
end)

function InvokeClient(Mode, Value)
	local ClientReturn = nil
	pcall(function()
		ClientReturn = ClientControl:InvokeClient(Player, Mode, Value)
	end)
	return ClientReturn
end

function TagHumanoid(humanoid, player)
	local Creator_Tag = Instance.new("ObjectValue")
	Creator_Tag.Name = "creator"
	Creator_Tag.Value = player
	Debris:AddItem(Creator_Tag, 2)
	Creator_Tag.Parent = humanoid
end

function UntagHumanoid(humanoid)
	for i, v in pairs(humanoid:GetChildren()) do
		if v:IsA("ObjectValue") and v.Name == "creator" then
			v:Destroy()
		end
	end
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 EffectPart = BasePart:Clone()
	EffectPart.Name = "Effect"
	EffectPart.Size = Vector3.new(0, 0, 0)
	EffectPart.CFrame=CFrame.new(Pos)
	EffectPart.Anchored = true
	EffectPart.CanCollide = false
	EffectPart.Transparency = 1
	local BillboardGui = Instance.new("BillboardGui")
	BillboardGui.Size = UDim2.new(3, 0, 3, 0)
	BillboardGui.Adornee = EffectPart
	local TextLabel = Instance.new("TextLabel")
	TextLabel.BackgroundTransparency = 1
	TextLabel.Size = UDim2.new(1, 0, 1, 0)
	TextLabel.Text = Text
	TextLabel.TextColor3 = Color
	TextLabel.TextScaled = true
	TextLabel.Font = Enum.Font.ArialBold
	TextLabel.Parent = BillboardGui
	BillboardGui.Parent = EffectPart
	Debris:AddItem(EffectPart, (Time + 0.1))
	EffectPart.Parent = game:GetService("Workspace")
	Delay(0, function()
		local Frames = (Time / Rate)
		for Frame = 1, Frames do
			wait(Rate)
			local Percent = (Frame / Frames)
			EffectPart.CFrame=CFrame.new(Pos) + Vector3.new(0, (5 * Percent), 0)
			TextLabel.TextTransparency = Percent
		end
		if EffectPart and EffectPart.Parent then
			EffectPart:Destroy()
		end
	end)
end

function MakeBlood(Part)
	if not Part then
		return
	end
	local Blood = BasePart:Clone()
	Blood.BrickColor = BrickColor.new("Bright red")
	Blood.Transparency = (math.random(0, 1) * 0.5)
	Blood.CanCollide = ((math.random() < 0.5 and false) or true)
	Blood.Size = Vector3.new((0.2 * math.random(1, 5)), (0.2 * math.random(1, 5)), (0.2 * math.random(1, 5)))
	Blood.Velocity= Part.Velocity + (Vector3.new((math.random() - 0.5), (math.random() - 0.5), (math.random() - 0.5)) * 30)
	Blood.RotVelocity = Part.RotVelocity + (Vector3.new((math.random() - 0.5), (math.random() - 0.5), (math.random() - 0.5)) * 20)
	Blood.CFrame= Part.CFrame * CFrame.new(((math.random() - 0.5) * 3), ((math.random() - 0.5) * 3), ((math.random() - 0.5) * 3)) * CFrame.Angles((math.pi * 2 * math.random()), (math.pi * 2 * math.random()), (math.pi * 2 * math.random()))
	Debris:AddItem(Blood, (math.random() * 4))
	Blood.Parent = game:GetService("Workspace")
end

function Blow(Hit)
	if not Hit or not Hit.Parent or not CheckIfAlive() or not Ready or not ToolEquipped or (tick() - LastSwing) > DamageWindow then
		return
	end
	local character = Hit.Parent
	if character == Character then
		return
	end
	if Hit:FindFirstChild("CanBlock") and Handle:FindFirstChild("Blockable") then
		local Ready = false
		local PossibleSounds = {Sounds.Clash1, Sounds.Clash2, Sounds.Clash3, Sounds.Clash4, Sounds.Clash5}
		local Sound = PossibleSounds[math.random(1, #PossibleSounds)]
		Sound:Play()
		Sparkles.Enabled = true
		Delay(0.2, function()
			Sparkles.Enabled = false
		end)
		Billboard(Handle.Position, "Block", 2, Color3.new(1, 1, 0))
	end
	local humanoid = character:FindFirstChild("Humanoid")
	local player = Players:GetPlayerFromCharacter(character)
	local RightArm = Character:FindFirstChild("Right Arm")
	if humanoid and humanoid.Health > 0 and humanoid ~= Humanoid and RightArm then
		local RightGrip = RightArm:FindFirstChild("RightGrip")
		if RightGrip and (RightGrip.Part0 == Handle or RightGrip.Part1 == Handle) then
			if player and player ~= Player and not Player.Neutral and not player.Neutral and Player.TeamColor == player.TeamColor then
				return --No team killing
			end
			Ready = false
			UntagHumanoid(humanoid)
			TagHumanoid(humanoid)
			local LocalDamage= math.floor(Damage * (0.9 + (math.random() * 0.2)) + 0.5)
			humanoid:TakeDamage(LocalDamage)
			Billboard(Hit.Position, ("-" .. tostring(LocalDamage)))
			local PossibleSounds = {Sounds.Hit1, Sounds.Hit2, Sounds.Hit3}
			local Sound = PossibleSounds[math.random(1, #PossibleSounds)]
			Sound:Play()
			if BloodEffects then
				local NumBloodEffects = math.ceil(LocalDamage / 10)
				for i = 1, math.random((NumBloodEffects - 1), (NumBloodEffects + 1)) do
					MakeBlood(Hit)
				end
			end
		end
	end
end

function Activated()
	if ToolEquipped and (tick() - LastSwing) >= SwingRate then
		Tool.Enabled = false
		Ready = true
		
		local PossibleSounds = {Sounds.Swoosh1, Sounds.Swoosh2}
		local Sound = PossibleSounds[math.random(1, #PossibleSounds)]
		Sound:Play()
		
		local AttackAnimations = {Animations.LeftSlash, Animations.RightSlash, Animations.Stab1, Animations.Stab2}
		local NewAnimation = AttackAnimations[math.random(1, #AttackAnimations)]
		while NewAnimation == CurrentAnimation do
			NewAnimation = AttackAnimations[math.random(1, #AttackAnimations)]
		end
		
		CurrentAnimation = NewAnimation
		
		InvokeClient("PlayAnimation", CurrentAnimation)

		LastSwing = tick()

		wait(SwingRate)
		
		if MouseDown then
			Activated()
		end
		
		Tool.Enabled = true
	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

function CheckIfAlive()
	return (Player and Player.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0)
end

function Equipped()
	Character = Tool.Parent
	Player = Players:GetPlayerFromCharacter(Character)
	PlayerGui = Player:FindFirstChild("PlayerGui")
	Humanoid = Character:FindFirstChild("Humanoid")
	if not CheckIfAlive() then
		return
	end
	if PlayerGui then
		WeaponHud.Parent = PlayerGui
	end
	InvokeClient("PlayAnimation", Animations.Equip)
	LastSwing = tick()
	Ready = false
	ToolEquipped = true
	for i, v in pairs(Animations) do
		if v and v.Animation then
			InvokeClient("Preload", v.Animation.AnimationId)
		end
	end
	ToolEquipped = true
end

function Unequipped()
	for i, v in pairs(Animations) do
		InvokeClient("StopAnimation", v)
	end
	WeaponHud.Parent = Tool
	ToolEquipped = false
	Ready = false
end

Handle.Touched:connect(Blow)

Tool.Equipped:connect(Equipped)
Tool.Unequipped:connect(Unequipped)

Spawn(function()
	while true do
		UpdateGui()
		wait(Rate)
	end
end)
