zayzaaa2030

Untitled

Jun 18th, 2022
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. local LocalPlayer = game:GetService'Players'.LocalPlayer
  2. local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
  3. local Humanoid;
  4. local Mouse = LocalPlayer:GetMouse()
  5.  
  6. local FindFirstChild, WaitForChild, IsA, GetChildren = game.findFirstChild, game.waitForChild, game.IsA, game.GetChildren
  7.  
  8. local IsSetUp, Names = {}, {
  9. 'Glock', 'Shotty', 'Uzi'
  10. }
  11.  
  12. local Connect = game.Loaded.Connect
  13.  
  14. local PlayingAnim = false
  15. local SetupClient = function(Gun)
  16. local Connections = {}; repeat
  17. Connections = getconnections(Gun.Activated)
  18. wait()
  19. until #Connections > 0
  20.  
  21. for I, V in pairs(Connections) do
  22. V:Disable()
  23. end
  24.  
  25. repeat
  26. wait()
  27. until Humanoid and Humanoid.Health > 0
  28.  
  29. local Fires = WaitForChild(Gun, 'Fires')
  30.  
  31. local Remote = WaitForChild(Gun, 'Fire')
  32. local FireServer = Remote.FireServer
  33.  
  34. local Loaded = Humanoid:LoadAnimation(Fires)
  35. local Play = Loaded.Play
  36.  
  37. local GName = Gun.Name
  38.  
  39. Connect(Gun.Activated, function()
  40. spawn(function()
  41. FireServer(Remote, Mouse.Hit)
  42. end)
  43. spawn(function()
  44. if PlayingAnim then return end
  45. PlayingAnim = true
  46. Play(Loaded, 0.1, 1, 2)
  47. Loaded.Stopped:Wait()
  48. if GName == 'Shotty' then
  49. wait(0.16)
  50. end
  51. PlayingAnim = false
  52. end)
  53. end)
  54. end
  55.  
  56. local OnChildAdded;
  57.  
  58. local onCharacterAdded = function(newCharacter)
  59. Character = newCharacter
  60. Humanoid = WaitForChild(newCharacter, 'Humanoid')
  61.  
  62. if OnChildAdded then
  63. OnChildAdded:Disconnect()
  64. OnChildAdded = nil
  65. end
  66.  
  67. OnChildAdded = newCharacter.ChildAdded:Connect(function(Tool)
  68. if IsA(Tool, 'Tool') and table.find(Names, Tool.Name) and not table.find(IsSetUp, Tool) then
  69. SetupClient(Tool); IsSetUp[#IsSetUp+1] = Tool
  70. end
  71. end)
  72. end
  73.  
  74. onCharacterAdded(Character)
  75. LocalPlayer.CharacterAdded:Connect(onCharacterAdded)
Add Comment
Please, Sign In to add comment