RazBerry916

Functioning Sword

Jun 3rd, 2023
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.92 KB | Source Code | 0 0
  1. game.Players.LocalPlayer:GetMouse().Button1Down:Connect(function()
  2.     if debounce==true then return end
  3.     local oldWalk=game.Players.LocalPlayer.Character.Humanoid.WalkSpeed
  4.     local oldJump=game.Players.LocalPlayer.Character.Humanoid.JumpPower
  5.     if hitstun==0 then
  6.     local now = (tick() - lastClick)
  7.     if now>=1 then
  8.         Light=1
  9.         lastClick=tick()
  10.     elseif now<1 then
  11.         lastClick=tick()
  12.     end
  13.     if game.Players.LocalPlayer.Character.CD.Value==false and game.Players.LocalPlayer.Character.Blocking.Value==false then
  14.         debounce=true
  15.             if mode ~="Ranged" then
  16.            
  17.                 game.Players.LocalPlayer.Character.Humanoid.WalkSpeed=10
  18.                 game.Players.LocalPlayer.Character.Humanoid.JumpPower=0
  19.                 game.ReplicatedStorage.Remotes.Attack:InvokeServer(game.Players.LocalPlayer:GetMouse().hit, Light, mode,false)
  20.             animations()
  21.            
  22.             print(Light)
  23.  
  24.             Light=Light+1
  25.         elseif mode== "Ranged" and Light==2 then
  26.             animations()
  27.             Light=1
  28.         elseif mode == "Ranged" and Light==1 then
  29.             animations()
  30.             Light=Light+1
  31.         end
  32.         if Light==6 then
  33.  
  34.             Light=1
  35.             wait(0.5)
  36.         end
  37.         if mode=="Sword" then
  38.            
  39.             local sound = Instance.new("Sound",game.Players.LocalPlayer.Character.HumanoidRootPart)
  40.             sound.SoundId="rbxassetid://8680211166"
  41.             sound:Play()
  42.             game:GetService("Debris"):AddItem(sound,2)
  43.             wait(attackWait)
  44.                 if game.Players.LocalPlayer.Character.Humanoid.WalkSpeed~=SwordWalkSpeed then
  45.                
  46.                         game.Players.LocalPlayer.Character.Humanoid.JumpPower=oldJump
  47.                         game.Players.LocalPlayer.Character.Humanoid.WalkSpeed=SwordWalkSpeed
  48.             end
  49.             elseif mode=="Ranged" then
  50.                 print("Worked")
  51.                 game.ReplicatedStorage.Remotes.Attack:InvokeServer(game.Players.LocalPlayer:GetMouse().hit, Light, mode,false)
  52.                 wait(0.05)
  53.                 if game.Players.LocalPlayer.Character.Humanoid.WalkSpeed~=RangedWalkSpeed then
  54.                     game.Players.LocalPlayer.Character.Humanoid.JumpPower=50
  55.                     game.Players.LocalPlayer.Character.Humanoid.WalkSpeed=RangedWalkSpeed  
  56.                 elseif  not game.Players.LocalPlayer.Character.Humanoid.JumpPower==50 then
  57.                     game.Players.LocalPlayer.Character.Humanoid.JumpPower=50
  58.                     game.Players.LocalPlayer.Character.Humanoid.WalkSpeed=RangedWalkSpeed  
  59.                
  60.                     end
  61.             end
  62.             print("ended")
  63.         debounce=false
  64. end
  65.     end
  66. end)
  67. game.Players.LocalPlayer:GetMouse().Button2Down:Connect(function()
  68.     if hitstun==0 then
  69.     if debounce==true then return end
  70.     if heavyReady==true then
  71.             if game.Players.LocalPlayer.Character.CD.Value==false and game.Players.LocalPlayer.Character.Blocking.Value==false then
  72.                 if mode=="Sword" then
  73.         debounce=true
  74.                     local oldWalk=game.Players.LocalPlayer.Character.Humanoid.WalkSpeed
  75.                     local oldJump=game.Players.LocalPlayer.Character.Humanoid.JumpPower
  76.                     game.Players.LocalPlayer.Character.Humanoid.WalkSpeed=10
  77.                     game.Players.LocalPlayer.Character.Humanoid.JumpPower=0
  78.                 heavyReady=false
  79.             HeavyAnim()
  80.                     game.ReplicatedStorage.Remotes.Attack:InvokeServer(game.Players.LocalPlayer:GetMouse().hit, 0, mode,true)
  81.  
  82.    
  83.             local sound = Instance.new("Sound",game.Players.LocalPlayer.Character.HumanoidRootPart)
  84.             sound.SoundId="rbxassetid://7545764969"
  85.             sound:Play()
  86.             game:GetService("Debris"):AddItem(sound,2)
  87.             wait(attackWait)
  88.             if game.Players.LocalPlayer.Character.Humanoid.WalkSpeed~=SwordWalkSpeed then
  89.                         if game.Players.LocalPlayer.Character.Humanoid.JumpPower~=oldJump then
  90.                             game.Players.LocalPlayer.Character.Humanoid.JumpPower=50
  91.                             game.Players.LocalPlayer.Character.Humanoid.WalkSpeed=SwordWalkSpeed
  92.  
  93.                         end
  94.             end
  95.  
  96.                     debounce=false
  97.                     wait(3)
  98.                     heavyReady=true
  99.                 elseif mode=="Ranged" then
  100.                     if heavyReady2==true then
  101.                         debounce=true
  102.                
  103.                     HeavyAnim()
  104.                     local oldWalk=game.Players.LocalPlayer.Character.Humanoid.WalkSpeed
  105.                     local oldJump=game.Players.LocalPlayer.Character.Humanoid.JumpPower
  106.                     game.Players.LocalPlayer.Character.Humanoid.WalkSpeed=0
  107.                     game.Players.LocalPlayer.Character.Humanoid.JumpPower=0
  108.                     game.Players.LocalPlayer.Character.HumanoidRootPart.Anchored=true
  109.                     heavyReady2=false
  110.                     game.ReplicatedStorage.Remotes.Attack:InvokeServer(game.Players.LocalPlayer:GetMouse().hit, 0, mode,true)
  111.                     wait(1.75)
  112.                     game.Players.LocalPlayer.Character.HumanoidRootPart.Anchored=false
  113.                     if game.Players.LocalPlayer.Character.Humanoid.WalkSpeed~=RangedWalkSpeed then
  114.                         game.Players.LocalPlayer.Character.Humanoid.JumpPower=50
  115.                         game.Players.LocalPlayer.Character.Humanoid.WalkSpeed=RangedWalkSpeed
  116.  
  117.                     end
  118.  
  119.                     debounce=false
  120.                     wait(10)
  121.                     heavyReady2=true
  122.                 end
  123.             end
  124.         end
  125.         end
  126.         end
  127. end)
  128. game:GetService("UserInputService").InputBegan:Connect(function(key,IsTyping)
  129.     if debounce==true then return end
  130.     if hitstun==0 then
  131.     if IsTyping==false then
  132.         if key.KeyCode== Enum.KeyCode.Q then
  133.             debounce=true
  134.             if mode=="Ranged" then
  135.      mode="Sword"
  136.                     game.ReplicatedStorage.Remotes.WeaponChange:InvokeServer(mode, SwordWalkSpeed, RangedWalkSpeed)
  137.                 Light=1
  138.                 print("Yes")
  139.             elseif mode=="Sword" then
  140.                 mode="Ranged"
  141.                 print("Yes")
  142.                     Light=1
  143.                     game.ReplicatedStorage.Remotes.WeaponChange:InvokeServer(mode, SwordWalkSpeed, RangedWalkSpeed)
  144.            
  145.             end
  146.  
  147.             wait(ChangeModeWait)
  148.         print(mode)
  149.             debounce=false
  150.         end
  151.         end
  152.         end
  153. end)
  154. game.ReplicatedStorage.Remotes.Blocking.OnClientEvent:Connect(function(enemy,status)
  155.     if status=="Blocked" then
  156.         local blockVFX = game.ReplicatedStorage.InsertParts.BlockSteelEffect:Clone()
  157.         for i, v in pairs(blockVFX:GetChildren()) do
  158.             spawn(function()
  159.                 v.Parent=enemy
  160.                 v.CFrame = enemy:FindFirstChild("Sword").CFrame * CFrame.Angles(0,0,0)
  161.                 game:GetService("Debris"):AddItem(v,0.5)
  162.                 local goal4 = {Transparency=1}
  163.                 local goal3
  164.                 if v.Name=="SteelEffect1" then
  165.                     local goal3 = {Size= Vector3.new(2.315, 1.641, 2.19)}
  166.                     local sound = Instance.new("Sound",enemy.HumanoidRootPart)
  167.                     sound.SoundId="rbxassetid://5763723309"
  168.                     sound:Play()
  169.                     game:GetService("Debris"):AddItem(sound,2)
  170.                     game:GetService("TweenService"):Create(v,TweenInfo.new(0.45),goal3):Play()
  171.                 elseif v.Name=="SteelEffect2" then
  172.                     local goal3 = {Size= Vector3.new(3.692, 4.005, 3.958)}
  173.                     game:GetService("TweenService"):Create(v,TweenInfo.new(0.45),goal3):Play()
  174.                 end
  175.  
  176.                 game:GetService("TweenService"):Create(v, TweenInfo.new(0.45),goal4):Play()
  177.             end)
  178.         end
  179.     end
  180. end)
  181.  
  182. game:GetService("UserInputService").InputBegan:Connect(function(key,IsTyping)
  183.     if IsTyping==false then
  184.         if hitstun==0 then
  185.             if mode~="Ranged" then
  186.         if key.KeyCode==Enum.KeyCode.F then
  187.             if debounce==true then return end
  188.             if game.Players.LocalPlayer.Character.Blocking.Value==false and game.Players.LocalPlayer.Character.CD.Value==false then
  189.                 debounce=true
  190.                 blocking=true
  191.                 BlockingAnim:Play()
  192.                 game.Players.LocalPlayer.Character.Humanoid.WalkSpeed=8
  193.                 game.Players.LocalPlayer.Character.Humanoid.JumpPower=0
  194.                 game.ReplicatedStorage.Remotes.Blocking:FireServer(true)
  195.             end
  196.         end
  197.         end
  198. end
  199.         end
  200. end)
Advertisement
Add Comment
Please, Sign In to add comment