Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- script.Parent:WaitForChild("lvl")
- Player = game.Players.LocalPlayer
- Player:WaitForChild("leaderstats")
- local Tool = script.Parent
- local Sword = Tool:WaitForChild("Handle")
- local myCharacter
- local myPlayer
- local myHumanoid
- local myTorso
- local myRightArm
- local myRightGrip
- local debris = game:GetService("Debris")
- local runServ = game:GetService("RunService")
- local SlashSound = Instance.new("Sound")
- SlashSound.SoundId = "rbxasset://sounds\\SwordSlash.wav"
- SlashSound.Parent = Tool
- SlashSound.Volume = 0
- local Whoosh1Sound
- local Whoosh2Sound
- local SlashAnim
- local SpecialAnim
- Bob=script.Parent.lvl
- BaseDmg = 0.5*Bob.Value
- Bob.Changed:connect(function(dmg)
- BaseDmg = 0.5 * dmg
- end)
- local lastAttackTime = 0
- local thisAttackTime
- local TOUCH_DAMAGE = 0
- local SLASH_DAMAGE = BaseDmg
- local SPECIAL_DAMAGE = BaseDmg
- local damage = TOUCH_DAMAGE
- local damageCo
- Tool.Enabled = true
- function tagHumanoid(humanoid, player)
- if humanoid ~= nil then
- creator = Instance.new("ObjectValue")
- creator.Name = "creator"
- creator.Value = player
- creator.Parent = humanoid
- debris:addItem(creator, 1)
- end
- end
- function untagHumanoid(humanoid)
- if humanoid ~= nil then
- local creatorTag = humanoid:FindFirstChild("creator")
- if creatorTag then creatorTag:Remove() end
- end
- end
- function blow(hit)
- if hit.Parent then
- local hitHumanoid = hit.Parent:FindFirstChild("Humanoid")
- myCharacter = Tool.Parent
- myHumanoid = myCharacter:FindFirstChild("Humanoid")
- myPlayer = game.Players:GetPlayerFromCharacter(myCharacter)
- if hitHumanoid ~= nil and myHumanoid ~= nil and myHumanoid ~= hitHumanoid then
- myRightArm = myCharacter:FindFirstChild("Right Arm")
- if myRightArm then
- myRightGrip = myRightArm:FindFirstChild("RightGrip")
- if myRightGrip and (myRightGrip.Part0 == Sword or myRightGrip.Part1 == Sword) then
- tagHumanoid(hitHumanoid, myPlayer)
- hitHumanoid:TakeDamage(damage)
- wait(0.1)
- untagHumanoid(hitHumanoid)
- end
- end
- end
- end
- end
- function damageChanger()
- damage = SLASH_DAMAGE
- wait(1)
- damage = TOUCH_DAMAGE
- end
- function slash()
- damageCo = coroutine.create(damageChanger)
- coroutine.resume(damageCo)
- if Whoosh1Sound then Whoosh1Sound:Stop() end
- if Whoosh2Sound then Whoosh2Sound:Stop() end
- if SpecialAnim then SpecialAnim:Stop() end
- if SlashSound then SlashSound:Play() end
- if SlashAnim then SlashAnim:Play() end
- end
- function special()
- damageCo = nil
- damage = SPECIAL_DAMAGE
- if SlashSound then SlashSound:Stop() end
- if SlashAnim then SlashAnim:Stop() end
- if SpecialAnim then SpecialAnim:Play() end
- wait(.4)
- if Whoosh1Sound then Whoosh1Sound:Play() end
- wait(.7)
- if Whoosh2Sound then Whoosh2Sound:Play() end
- wait(.1)
- damage = TOUCH_DAMAGE
- end
- function onActivated()
- if not Tool.Enabled then return end
- Tool.Enabled = false
- myCharacter = Tool.Parent
- if not myCharacter then return end
- myHumanoid = myCharacter:FindFirstChild("Humanoid")
- if not myHumanoid then return end
- RightArm = myCharacter:FindFirstChild("Right Arm")
- if not RightArm then return end
- thisAttackTime = runServ.Stepped:wait()
- if (thisAttackTime - lastAttackTime < 0.2) then
- SpecialAnim = myHumanoid:LoadAnimation(Tool.SlashNStabAttempt2)
- Whoosh1Sound = Tool:FindFirstChild("Whoosh1")
- Whoosh2Sound = Tool:FindFirstChild("Whoosh2")
- special()
- else
- SlashAnim = myHumanoid:LoadAnimation(Tool.Slash)
- slash()
- end
- lastAttackTime = thisAttackTime
- Tool.Enabled = true
- end
- function onUnequipped()
- if SlashSound then SlashSound:Stop() end
- if SlashAnim then SlashAnim:Stop() end
- if Whoosh1Sound then Whoosh1Sound:Stop() end
- if Whoosh2Sound then Whoosh2Sound:Stop() end
- if SpecialAnim then SpecialAnim:Stop() end
- end
- Tool.Activated:connect(onActivated)
- Tool.Unequipped:connect(onUnequipped)
- Sword.Touched:connect(blow)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement