Advertisement
Aquarius_Raverus

testt

Apr 22nd, 2020
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.46 KB | None | 0 0
  1. -- Sword Server Script
  2. -- By Sylvern
  3. -- 4/19/2020
  4.  
  5. --[[
  6.    
  7.     Add animations when received.
  8.     Animations switch are Underhand and Overhand.
  9.    
  10. ]]--
  11.  
  12. local Player = script:FindFirstAncestorWhichIsA("Player") or game:GetService("Players"):GetPlayerFromCharacter(script.Parent.Parent)
  13. local Players = game:GetService("Players")
  14.  
  15. local Debris = game:GetService("Debris")
  16. local Storage = game:GetService("ReplicatedStorage")
  17.  
  18. local Tool = script.Parent
  19.  
  20. local Handle = Tool:WaitForChild('Handle')
  21.  
  22. local Animations = Tool:WaitForChild("Animations")
  23. local Particle = Storage:WaitForChild("ParticleEmitter")
  24.  
  25. local Configuration = Tool:WaitForChild("Configuration")
  26.  
  27. local Damage = Configuration:WaitForChild('Damage')
  28. local BlockDamage = Configuration:WaitForChild('BlockDamage')
  29.  
  30. local Event = script.Parent:WaitForChild("ChangeAnimation")
  31.  
  32. local Cooldown = 0.3
  33.  
  34. local RaycastHitBox = require(Tool:WaitForChild("RaycastHitbox"))
  35. local HitBox = RaycastHitBox:Initialize(Handle)
  36.  
  37. local Ev = Tool:WaitForChild("Weld")
  38.  
  39. local AnimationOn = '1' -- underhand
  40.  
  41. --[[
  42.     Animation 1 = Underhand
  43.     Animation 2 = Overhand
  44. ]]--
  45.  
  46.  
  47. local OnCooldown = false
  48.  
  49.  
  50. HitBox.OnHit:Connect(function(hit, humanoid)
  51.     if  hit.Parent.Name == Player.Name then return end
  52.        
  53.         if hit.Parent.Humanoid then
  54.             if game.Players:FindFirstChild(hit.Parent.Name) then
  55.                 warn(hit.Parent.Name)
  56.                
  57.                 local playerPlr = game.Players:FindFirstChild(hit.Parent.Name)
  58.                
  59.                 if playerPlr.isBlocking.Value == 'Yes' then
  60.                     humanoid:TakeDamage(BlockDamage.Value)
  61.                     cloneBlood(hit.Parent.HumanoidRootPart)
  62. --                  Knockback(hit.Parent.HumanoidRootPart, Player.Character.HumanoidRootPart)
  63.             --      KnockForward(Player.Character.HumanoidRootPart)
  64.                    
  65.                 elseif playerPlr.isBlocking.Value == 'No' or playerPlr.isBlocking.Value == 'None' then
  66.                     humanoid:TakeDamage(Damage.Value)
  67.                     cloneBlood(hit.Parent.HumanoidRootPart)
  68.                     Knockback(hit.Parent.HumanoidRootPart, Player.Character.HumanoidRootPart)
  69.                     KnockForward(Player.Character.HumanoidRootPart)
  70.                 end
  71.         else
  72.             warn(hit.Parent.Name)
  73.            
  74.             Slowness(hit.Parent.HumanoidRootPart)
  75.             cloneBlood(hit.Parent.HumanoidRootPart)
  76.             Knockback(hit.Parent.HumanoidRootPart, Player.Character.HumanoidRootPart)
  77.            
  78.             KnockForward(Player.Character.HumanoidRootPart)
  79.            
  80.             hit.Parent.Humanoid:TakeDamage(Damage.Value)
  81.             end
  82.         end
  83.    
  84.     -- Add hit animation to player.
  85. end)
  86.  
  87. function cloneBlood(plrModel)
  88.     local Clone = Particle:Clone()
  89.     Clone.Parent = plrModel
  90.     Debris:AddItem(Clone, 0.8)
  91. end
  92.  
  93. function Slowness(plrModel)
  94.     local BV = Instance.new("BodyVelocity", plrModel)
  95.     BV.Name = 'Slowness'
  96.     BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  97.     BV.P = 2000
  98.     BV.Velocity = Vector3.new(0,0,0)
  99.     Debris:AddItem(BV, 0.2)
  100. end
  101.  
  102. function KnockForward(plrModel)
  103.     local BV = Instance.new("BodyVelocity", plrModel)
  104.     BV.Name = 'Knockback'
  105.     BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  106.     BV.P = 2000
  107.     BV.Velocity = plrModel.CFrame.lookVector * 15
  108.     Debris:AddItem(BV, 0.2)
  109. end
  110.  
  111. function Knockback(plrModel, plrAttacking)
  112.     local BV = Instance.new("BodyVelocity", plrModel)
  113.     BV.Name = 'Knockback'
  114.     BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  115. --  BV.P = 2000
  116.     BV.Velocity =  plrAttacking.CFrame.lookVector * 18
  117.     Debris:AddItem(BV, 0.2)
  118. end
  119.  
  120. function LoadAnimation(plrModel, animation)
  121.     local Animation = plrModel.Humanoid:LoadAnimation(animation)
  122.     Animation:Play()
  123. end
  124.  
  125. Tool.Activated:Connect(function()
  126.     if OnCooldown then return end -- Debounce cooldown.
  127.    
  128.     OnCooldown = true
  129.     LoadAnimation(game.Workspace[Player.Name], Animations[AnimationOn])
  130.     warn(AnimationOn)
  131.     HitBox:HitStart()
  132.     wait(1)
  133.     HitBox:HitStop()
  134.    
  135.     wait(Cooldown)
  136.     OnCooldown = false
  137.    
  138.     -- Play animation.
  139. end)
  140.  
  141. Event.OnServerEvent:Connect(function(plr)    -- 1 is underhand and 2 is overhand
  142.     if AnimationOn == '1' then
  143.         AnimationOn = '2'
  144.         warn(AnimationOn)
  145.     elseif AnimationOn == '2' then
  146.         AnimationOn = '1'
  147.         warn(AnimationOn)
  148.     end
  149. end)
  150.  
  151.  
  152. Ev.OnServerEvent:Connect(function(plr, action)
  153.    
  154.     if action == 'UnEquip' then
  155.         local char = plr.Character
  156.         local copy = Storage:WaitForChild("SwordCopy"):Clone()
  157.        
  158.         copy.Parent = char
  159.         copy.GripWeld.Part1 = char.UpperTorso
  160.         copy.GripWeld.C0 = CFrame.new(-1.12,-1.02,1)
  161.         copy.GripWeld.C0 = copy.GripWeld.C0 * CFrame.fromEulerAnglesXYZ(math.rad(90),math.rad(-165),-20.5)
  162.     end
  163.    
  164.     if action == 'Equip' then
  165.         plr.Character:FindFirstChild('SwordCopy'):Destroy()
  166.     end
  167. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement