Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ₪ Kolbias May 12, 2017 Edited June 2, 2017
- --[[-----------------------------------------------------------------------------------
- >> VARIABLES
- -------------------------------------------------------------------------------------]]
- local Players = game:FindService("Players")
- local Run = game:FindService("RunService")
- local Debris = game:FindService("Debris")
- local Tool = script.Parent
- local Sword = Tool:WaitForChild("Handle")
- local Slash_Sound = Sword:WaitForChild("Slash_Sound")
- local Lunge_Sound = Sword:WaitForChild("Lunge_Sound")
- local Unsheath_Sound = Sword:WaitForChild("Unsheath_Sound")
- local Stats = Sword:WaitForChild("Stats")
- local Idle_Damage = Stats.Idle.Value
- local Slash_Damage = Stats.Slash.Value
- local Lunge_Damage = Stats.Lunge.Value
- local damage = Idle_Damage
- --[[-----------------------------------------------------------------------------------
- >> TAG HUMANOID FUNCTION
- -------------------------------------------------------------------------------------]]
- local function TagHumanoid(S_Player, Other)
- local Tag = Instance.new("ObjectValue")
- Tag.Value = S_Player
- Tag.Name = "creator"
- Tag.Parent = Other
- Debris:AddItem(Tag, 0.25)
- Other:TakeDamage(damage)
- end
- --[[-----------------------------------------------------------------------------------
- >> DAMAGE FUNCTION
- -------------------------------------------------------------------------------------]]
- local function onTouched(Hit)
- local Other = Hit.Parent:FindFirstChild("Humanoid")
- if Other then
- local Arm = Tool.Parent:FindFirstChild("Right Arm")
- if Arm then
- local Grip = Arm:FindFirstChild("RightGrip")
- if (Grip and (Grip.Part0 == Arm or Grip.Part1 == Sword)) then
- local O_Player = Players:GetPlayerFromCharacter(Hit.Parent)
- if O_Player then
- local S_Player = Players:GetPlayerFromCharacter(Tool.Parent)
- if (S_Player and (O_Player.TeamColor ~= S_Player.TeamColor)) then
- TagHumanoid(S_Player, Other)
- end
- else
- Other:TakeDamage(damage)
- end
- end
- end
- end
- end
- --[[-----------------------------------------------------------------------------------
- >> SLASH FUNCTION
- -------------------------------------------------------------------------------------]]
- local function Slash()
- damage = Slash_Damage
- Slash_Sound:Play()
- local Animation = Instance.new("StringValue")
- Animation.Name = "toolanim"
- Animation.Value = "Slash"
- Animation.Parent = Tool
- end
- --[[-----------------------------------------------------------------------------------
- >> LUNGE FUNCTION
- -------------------------------------------------------------------------------------]]
- local function Lunge()
- damage = Lunge_Damage
- Lunge_Sound:Play()
- local Animation = Instance.new("StringValue")
- Animation.Name = "toolanim"
- Animation.Value = "Lunge"
- Animation.Parent = Tool
- wait(0.25)
- Tool.GripUp = Vector3.new(1, 0, 0)
- wait(0.75)
- Tool.GripUp = Vector3.new(0, 0, 1)
- end
- --[[-----------------------------------------------------------------------------------
- >> UNSHEATH FUNCTION
- -------------------------------------------------------------------------------------]]
- local function onEquipped()
- Unsheath_Sound:Play()
- local Humanoid = Tool.Parent.Humanoid
- Humanoid.Died:Connect(function()
- Debris:AddItem(Tool, 0.75)
- end)
- end
- --[[-----------------------------------------------------------------------------------
- >> MAIN FUNCTION
- -------------------------------------------------------------------------------------]]
- local Enabled = true
- local Last_Attack = 0
- local function onActivated()
- if not Enabled then
- return
- end
- Enabled = false
- local Cooldown = Run.Stepped:wait()
- if (Cooldown - Last_Attack < 0.2) then
- Lunge()
- else
- Slash()
- end
- Last_Attack = Cooldown
- damage = Idle_Damage
- Enabled = true
- end
- --[[-----------------------------------------------------------------------------------
- >> CONNECTIONS
- -------------------------------------------------------------------------------------]]
- Tool.Equipped:Connect(onEquipped)
- Tool.Activated:Connect(onActivated)
- Sword.Touched:Connect(onTouched)
- -- ₪ Kolbias May 12, 2017 Edited June 2, 2017
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement