Advertisement
HowToRoblox

SwordClient

Apr 20th, 2022
2,286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.65 KB | None | 0 0
  1. local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
  2.  
  3. local idleAnim = character:WaitForChild("Humanoid"):LoadAnimation(script.IdleAnimation)
  4.  
  5. local animCombo = {
  6.     character:WaitForChild("Humanoid"):LoadAnimation(script.Swing1Animation),
  7.     character:WaitForChild("Humanoid"):LoadAnimation(script.Swing2Animation),
  8.     character:WaitForChild("Humanoid"):LoadAnimation(script.Swing3Animation),
  9. }
  10.  
  11. local currentCombo = 1
  12.    
  13.    
  14. script.Parent.Equipped:Connect(function()
  15.    
  16.     game.ReplicatedStorage.SwordRE:FireServer("connectm6d", script.Parent.BodyAttach)
  17.    
  18.     character.RightHand.ToolM6D:GetPropertyChangedSignal("Part1"):Wait()
  19.     idleAnim:Play()
  20. end)
  21.  
  22.  
  23. script.Parent.Unequipped:Connect(function()
  24.  
  25.     game.ReplicatedStorage.SwordRE:FireServer("disconnectm6d")
  26.    
  27.     idleAnim:Stop()
  28. end)
  29.  
  30.  
  31. local cooldown = false
  32.  
  33. script.Parent.Activated:Connect(function()
  34.    
  35.     if cooldown then return end
  36.    
  37.     cooldown = true
  38.    
  39.     game.ReplicatedStorage.SwordRE:FireServer("attack", script.Parent.BodyAttach)
  40.    
  41.     animCombo[currentCombo]:Play()
  42.    
  43.     character.HumanoidRootPart.Velocity = character.HumanoidRootPart.CFrame.LookVector * 100 * Vector3.new(1, 0, 1)
  44.    
  45.     currentCombo += 1
  46.     if currentCombo > #animCombo then currentCombo = 1 end
  47.    
  48.     local previousCombo = currentCombo
  49.    
  50.     spawn(function()
  51.        
  52.         wait(3)
  53.        
  54.         if currentCombo == previousCombo then
  55.             currentCombo = 1
  56.         end
  57.     end)
  58.    
  59.     wait(0.5)
  60.    
  61.     cooldown = false
  62. end)
  63.  
  64.  
  65. game.ReplicatedStorage.SwordRE.OnClientEvent:Connect(function(bodyAttach)
  66.    
  67.     bodyAttach.Slash:Play()
  68.    
  69.     bodyAttach.Trail.Enabled = true
  70.     wait(0.3)
  71.     bodyAttach.Trail.Enabled = false
  72. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement