Hasli4

Untitled

Nov 15th, 2026
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1.  
  2. local Players = game:GetService("Players")
  3.  
  4. local player = Players.LocalPlayer
  5. local tool = script.Parent
  6.  
  7. local punchEvent = tool:WaitForChild("PunchEvent")
  8.  
  9. -- ВСТАВЬ СЮДА ID СВОЕЙ АНИМАЦИИ
  10. local ANIMATION_ID = "rbxassetid://123456789012345"
  11.  
  12. -- Перезарядка удара
  13. local COOLDOWN = 0.65
  14.  
  15. local lastPunch = 0
  16. local animationTrack = nil
  17.  
  18. -- Создаём анимацию
  19. local punchAnimation = Instance.new("Animation")
  20. punchAnimation.AnimationId = ANIMATION_ID
  21.  
  22. -- Загружаем анимацию персонажа
  23. local function loadAnimation()
  24.  
  25. local character = player.Character or player.CharacterAdded:Wait()
  26.  
  27. local humanoid = character:WaitForChild("Humanoid")
  28. local animator = humanoid:WaitForChild("Animator")
  29.  
  30. local success, result = pcall(function()
  31. return animator:LoadAnimation(punchAnimation)
  32. end)
  33.  
  34. if not success then
  35. warn("Не удалось загрузить анимацию:", result)
  36. return
  37. end
  38.  
  39. animationTrack = result
  40.  
  41. animationTrack.Priority = Enum.AnimationPriority.Action
  42. animationTrack.Looped = false
  43. end
  44.  
  45. -- Экипировка оружия
  46. tool.Equipped:Connect(function()
  47. loadAnimation()
  48. end)
  49.  
  50. -- Нажатие ЛКМ
  51. tool.Activated:Connect(function()
  52.  
  53. local now = os.clock()
  54.  
  55. if now - lastPunch < COOLDOWN then
  56. return
  57. end
  58.  
  59. lastPunch = now
  60.  
  61. -- Загружаем анимацию, если необходимо
  62. if not animationTrack then
  63. loadAnimation()
  64. end
  65.  
  66. -- Проигрываем замах
  67. if animationTrack then
  68.  
  69. if animationTrack.IsPlaying then
  70. animationTrack:Stop(0.03)
  71. end
  72.  
  73. animationTrack:Play(0.04, 1, 1)
  74.  
  75. end
  76.  
  77. -- Отправляем запрос серверу
  78. punchEvent:FireServer()
  79. end)
  80.  
  81. -- Снятие перчаток
  82. tool.Unequipped:Connect(function()
  83.  
  84. if animationTrack then
  85. animationTrack:Stop(0.1)
  86. animationTrack = nil
  87. end
  88.  
  89. end)
  90.  
  91. -- Сбрасываем старую анимацию после перерождения
  92. player.CharacterAdded:Connect(function()
  93. animationTrack = nil
  94. end)
  95.  
Advertisement
Add Comment
Please, Sign In to add comment