Advertisement
Firebirdzz

Example 2.1

Dec 19th, 2024
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.75 KB | None | 0 0
  1. -- Prison Orb (clientSided)
  2.  
  3. local tool = script.Parent.Parent
  4. local player, userInputService, runService, effects, remoteEvents, mouse = game.Players.LocalPlayer,  game:GetService("UserInputService"),  game:GetService("RunService"), tool.Effects.Z, tool:WaitForChild("Effects").Z.RemoteEvents, game.Players.LocalPlayer:GetMouse()
  5. local isPressing, equipped = false, false
  6. local char = player.Character
  7. local hmrp = char.HumanoidRootPart
  8.  
  9. globalRenderstepConnection = nil
  10.  
  11. tool.Equipped:Connect(function()
  12.     equipped = true
  13. end)
  14.  
  15. tool.Unequipped:Connect(function()
  16.     equipped = false
  17. end)
  18.  
  19. userInputService.InputBegan:Connect(function(input, gameprocess)
  20.     if gameprocess then return end
  21.     if input.KeyCode == Enum.KeyCode.Z and equipped == true then
  22.         print(player.Name.." has pressed Z. It's being held down.")
  23.        
  24.         local root = char:WaitForChild("HumanoidRootPart")
  25.        
  26.         local clientRenderstepConnection = runService.RenderStepped:Connect(function()
  27.             local rootPos, mousePos = root.Position, mouse.Hit.Position
  28.             root.CFrame = CFrame.new(rootPos, Vector3.new(mousePos.X, rootPos.Y, mousePos.Z))
  29.         end)
  30.  
  31.         globalRenderstepConnection = clientRenderstepConnection
  32.        
  33.         local rootCFrame = root.CFrame
  34.        
  35.         remoteEvents:WaitForChild("ChargeAttack"):FireServer(rootCFrame)
  36.        
  37.     end
  38. end)
  39.  
  40.  
  41. userInputService.InputEnded:Connect(function(output, gameprocess)
  42.     if gameprocess then return end
  43.     if output.KeyCode == Enum.KeyCode.Z and equipped == true then  
  44.         print(player.Name.." has stopped pressing Z.")
  45.        
  46.         local rootCFrame = player.Character.HumanoidRootPart.CFrame
  47.         local attackCFrame = rootCFrame * CFrame.new(0,0,-120)
  48.        
  49.         remoteEvents:WaitForChild("StartAttack"):FireServer(attackCFrame)
  50.  
  51.         globalRenderstepConnection:Disconnect()
  52.        
  53.     end
  54. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement