Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- THE NEW SCRIPT WITH THE NEW ANIMATIONS
- sp = script.Parent
- r = game:service("RunService")
- debris = game:GetService("Debris")
- anims = {"RightSlash","LeftSlash","OverHeadSwing","LeftSwingFast","RightSwingFast"}
- Sounds = {{145180512, "Metal"}, {145180522, "Metal"}, {145180533, "Wood"}, {145180541, "Wood"}, {145180529, "Slash"}, {145180550, "Slash"}}
- WoodSounds = {}
- MetalSounds = {}
- SlashSounds = {}
- basedamage = 10
- slashdamage = 20
- swingdamage = 30
- damage = basedamage
- sword = sp:WaitForChild('Handle')
- sp.Taunting.Value = false
- local UnsheathSound = Instance.new("Sound")
- UnsheathSound.SoundId = "http://www.roblox.com/Asset/?id=145180523"
- UnsheathSound.Parent = sword
- UnsheathSound.Volume = .2
- for _,Sound in pairs(Sounds) do
- local S = Instance.new("Sound")
- S.SoundId = "http://www.roblox.com/Asset/?id=" .. Sound[1]
- S.Parent = sword
- S.Volume = .2
- if Sound[2] == "Wood" then
- table.insert(WoodSounds, S)
- elseif Sound[2] == "Metal" then
- table.insert(MetalSounds, S)
- elseif Sound[2] == "Slash" then
- table.insert(SlashSounds, S)
- end
- end
- function waitfor(parent,name)
- while true do
- local child = parent:FindFirstChild(name)
- if child ~= nil then
- return child
- end
- wait()
- end
- end
- waitfor(sp,"Taunting")
- waitfor(sp,"RunAnim")
- local Halt = false;
- function blow(hit)
- if hit:findFirstChild("IsShield") then
- damage = 0
- pcall(function()
- if hit.IsShield.Value == "Wood" then
- WoodSounds[math.random(#WoodSounds)]:Play()
- elseif hit.IsShield.Value == "Metal" then
- MetalSounds[math.random(#MetalSounds)]:Play()
- else
- WoodSounds[math.random(#WoodSounds)]:Play()
- end
- end);
- return
- end
- if Halt then return end;
- Halt = true;
- if hit.Parent ~= nil then
- local humanoid = hit.Parent:findFirstChild("Humanoid") or hit.Parent:findFirstChild("Human")
- local vCharacter = sp.Parent
- if vCharacter ~= nil then
- local vPlayer = game.Players:playerFromCharacter(vCharacter)
- if vPlayer ~= nil then
- local hum = vCharacter:findFirstChild("Humanoid") or vCharacter:findFirstChild("Human")
- if humanoid ~= nil then
- if hum ~= nil and humanoid ~= hum then
- local right_arm = vCharacter:FindFirstChild("Right Arm")
- if right_arm ~= nil then
- local joint = right_arm:FindFirstChild("RightGrip")
- if joint ~= nil and (joint.Part0 == sword or joint.Part1 == sword) then
- tagHumanoid(humanoid,vPlayer)
- humanoid:TakeDamage(damage)
- wait(.3)
- end
- end
- end
- end
- end
- end
- end
- Halt = false;
- end
- function tagHumanoid(humanoid,player)
- for i,v in ipairs(humanoid:GetChildren()) do
- if v.Name == "creator" then
- v:Destroy()
- end
- end
- local creator_tag = Instance.new("ObjectValue")
- creator_tag.Value = player
- creator_tag.Name = "creator"
- creator_tag.Parent = humanoid
- debris:AddItem(creator_tag,1)
- end
- sp.Enabled = true
- function onActivated()
- if sp.Enabled and not sp.Taunting.Value then
- sp.Enabled = false
- local character = sp.Parent;
- local humanoid = character.Humanoid
- if humanoid == nil then
- print("Humanoid not found")
- return
- end
- SlashSounds[math.random(#SlashSounds)]:Play()
- local newanim = anims[math.random(1,#anims)]
- while newanim == sp.RunAnim.Value do
- newanim = anims[math.random(1,#anims)]
- end
- sp.RunAnim.Value = newanim
- if newanim == "OverHeadSwing" then
- damage = swingdamage
- else
- damage = slashdamage
- end
- wait(.75)
- damage = basedamage
- sp.Enabled = true
- end
- end
- function onEquipped()
- UnsheathSound:play()
- end
- sp.Activated:connect(onActivated)
- sp.Equipped:connect(onEquipped)
- connection = sword.Touched:connect(blow)
- THE OLD SCRIPT WITH THE OLD ANIMATIONS
- r = game:GetService("RunService")
- ching = false
- sword = script.Parent.Handle
- Tool = script.Parent
- previousHealth = 1
- script.Parent.ToolTip = "Base damage: " .. script.Parent.MinDmg.Value .. "-" .. script.Parent.MaxDmg.Value .. " | Critical damage: " .. (script.Parent.CritMagnitude.Value/100).. "x"
- function blow(hit)
- if ching == true then return end
- local humanoid = hit.Parent:FindFirstChild("Human") or hit.Parent:FindFirstChild("Humanoid")
- local vCharacter = Tool.Parent
- local vPlayer = Game.Players:GetPlayerFromCharacter(vCharacter)
- --Did the weapon hit player? Check if PvP is enabled.
- if humanoid == nil then
- local hitPlayer = Game.Players:GetPlayerFromCharacter(hit.Parent)
- if hitPlayer ~= nil then
- if game.Workspace.GAME_PROPERTIES.HasPvP.Value == true and hitPlayer.Stats.InPvP.Value == true and hitPlayer.leaderstats.Lvl.Value >= game.Workspace.GAME_PROPERTIES.PvPLevelMinimum.Value then --Is the player in PvP areas?
- if hitPlayer.leaderstats.Lvl.Value >= vPlayer.leaderstats.Lvl.Value - game.Workspace.GAME_PROPERTIES.PvPLevelRange.Value and hitPlayer.leaderstats.Lvl.Value <= vPlayer.leaderstats.Lvl.Value + game.Workspace.GAME_PROPERTIES.PvPLevelRange.Value then
- humanoid = hit.Parent:FindFirstChild("Humanoid")
- end
- end
- end
- end
- --If humanoid is found, damage.
- if humanoid ~= nil then
- ching = true
- local damage = math.random(script.Parent.MinDmg.Value+math.floor(vPlayer.attributes.Strength.Value/2),script.Parent.MaxDmg.Value+math.floor(vPlayer.attributes.Strength.Value/2))+math.floor(vPlayer.leaderstats.Lvl.Value/5)
- local hitroll = math.random(1, 100)
- local critroll = math.random(1, 100)
- --Is the target a player? Have armor reduce damage taken.
- if Game.Players:GetPlayerFromCharacter(hit.Parent) ~= nil then
- if Game.Workspace.GAME_PROPERTIES.BaseHitChance.Value == 1 then
- damage = math.floor(damage * (1 - (Game.Players:GetPlayerFromCharacter(hit.Parent).Stats.Defense.Value / 100)))
- elseif Game.Workspace.GAME_PROPERTIES.BaseHitChance.Value == 2 then
- damage = math.floor(damage - Game.Players:GetPlayerFromCharacter(hit.Parent).Stats.Defense.Value)
- end
- if damage < 1 then damage = 1 end --Sets minimum damage to 1.
- end
- --Hit and critical modifier.
- if hitroll > Game.Workspace.GAME_PROPERTIES.BaseHitChance.Value + (vPlayer.attributes.Dexterity.Value * (Game.Workspace.GAME_PROPERTIES.HitChanceDexMagnitude.Value/100)) then
- damage = 0
- end
- if critroll <= Game.Workspace.GAME_PROPERTIES.BaseCritChance.Value + (vPlayer.attributes.Dexterity.Value * (Game.Workspace.GAME_PROPERTIES.CritChanceDexMagnitude.Value/100)) then
- damage = damage * (script.Parent.CritMagnitude.Value / 100) -- Percentage.
- end
- --Enemy health bar GUI
- if vPlayer.PlayerGui:FindFirstChild("EnemyInfo") ~= nil and humanoid.Health > 0 then
- vPlayer.PlayerGui:FindFirstChild("EnemyInfo").EnemyBar.TickUntilRemove.Value = 200
- vPlayer.PlayerGui:FindFirstChild("EnemyInfo").EnemyBar.Tag.Value = humanoid.Parent
- end
- --Damages humanoid
- previousHealth = humanoid.Health
- humanoid:TakeDamage(damage)
- tagHumanoid(humanoid, vPlayer, damage)
- --Floating damage text
- local part = Instance.new("BillboardGui")
- part.Size = UDim2.new(0,50,0,100)
- part.StudsOffset = Vector3.new(0,2,0)
- local part2 = Instance.new("TextLabel")
- dt = Game.ReplicatedStorage.DynamicText:Clone()
- part2.Font = "SourceSansBold"
- part2.FontSize = "Size24"
- part2.TextStrokeTransparency = 1
- part2.Size = UDim2.new(1,0,1,0)
- part2.Position = UDim2.new(0,0,0,0)
- part2.BackgroundTransparency = 1
- part2.Parent = part
- dt.Parent = part2
- dt.Disabled = false
- part.Parent = humanoid.Parent.Head
- part.Adornee = part.Parent
- --Shows text depending on conditions. Tells either miss or number.
- if (damage == 0) then
- part2.TextColor3 = Color3.new(0,0.5,1)
- part2.Text = "Miss!"
- else
- part2.TextColor3 = Color3.new(1,1,1)
- if critroll <= Game.Workspace.GAME_PROPERTIES.BaseCritChance.Value + (vPlayer.attributes.Dexterity.Value * (Game.Workspace.GAME_PROPERTIES.CritChanceDexMagnitude.Value/100)) then
- part2.TextColor3 = Color3.new(1,1,0)
- part2.FontSize = "Size36"
- part2.Text = ""..damage.."!"
- else
- part2.Text = ""..damage..""
- end
- end
- wait(1)
- ching = false
- wait(.1)
- --untagHumanoid(humanoid)
- end
- end
- function tagHumanoid(humanoid, player, damage)
- local creator_tag = Instance.new("ObjectValue", humanoid)
- creator_tag.Value = player
- creator_tag.Name = "creator"
- local damage_tag = Instance.new("IntValue", creator_tag)
- if humanoid.Health < 1 then
- damage_tag.Value = math.ceil(previousHealth)
- else
- damage_tag.Value = math.ceil(damage)
- end
- damage_tag.Name = "damage"
- 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()
- local anim = Instance.new("StringValue")
- anim.Name = "toolanim"
- anim.Value = "Slash"
- anim.Parent = Tool
- end
- function lunge()
- local anim = Instance.new("StringValue")
- anim.Name = "toolanim"
- anim.Value = "Lunge"
- anim.Parent = Tool
- force = Instance.new("BodyVelocity")
- force.velocity = Vector3.new(0,4000,0) --Tool.Parent.Torso.CFrame.lookVector * 80
- force.Parent = Tool.Parent.Torso
- wait(.25)
- swordOut()
- wait(.25)
- force.Parent = nil
- wait(.5)
- 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
- function onActivated()
- if not Tool.Enabled then return end
- Tool.Enabled = false
- local character = Tool.Parent;
- local humanoid = character.Humanoid
- if humanoid == nil then return end
- attack()
- wait(1)
- Tool.Enabled = true
- end
- function onEquipped()
- end
- script.Parent.Activated:connect(onActivated)
- script.Parent.Equipped:connect(onEquipped)
- connection = sword.Touched:connect(blow)
Advertisement
Add Comment
Please, Sign In to add comment