Anukun_Lucifer

AxeChopClient

Sep 5th, 2025
604
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.56 KB | Source Code | 0 0
  1. local AxeTool = script.Parent
  2. local treeChopRequestRemote = game.ReplicatedStorage:WaitForChild("TreeChopRequest")
  3. local localPalyer = game.Players.LocalPlayer
  4. local damagePart = AxeTool:FindFirstChild("DamagePart")
  5. local slashSound = AxeTool:FindFirstChild("SlashSound")
  6. local AxeAnimation = AxeTool:FindFirstChild("AnimAxe")
  7.  
  8. local isAnimationPlaying = false
  9. local animationTrack , animationStoppedConnection
  10.  
  11. local ANIMATION_DELAY = 0.5
  12.  
  13. local function resetAnimationState()
  14.     isAnimationPlaying = false
  15.     if animationStoppedConnection then
  16.         animationStoppedConnection:Disconnect()
  17.         animationStoppedConnection = nil
  18.     end
  19.     if animationTrack then
  20.         animationTrack:Stop()
  21.         animationTrack = nil
  22.     end
  23. end
  24.  
  25. local function playChopAnimation()
  26.     if isAnimationPlaying then return end
  27.     local character = localPalyer.Character or localPalyer.CharacterAdded:Wait()
  28.     local humaiond = character:FindFirstChildOfClass("Humanoid")
  29.     if not humaiond then return end
  30.     if AxeAnimation then
  31.         animationTrack = humaiond:LoadAnimation(AxeAnimation)
  32.         isAnimationPlaying = true
  33.         animationTrack:Play()
  34.         if slashSound then
  35.             slashSound:Play()
  36.         end
  37.         treeChopRequestRemote:FireServer(damagePart)
  38.         animationStoppedConnection = animationTrack.Stopped:Connect(function()
  39.             task.wait(ANIMATION_DELAY)
  40.             resetAnimationState()
  41.         end)
  42.     else
  43.         treeChopRequestRemote:FireServer(damagePart)
  44.         if slashSound then
  45.             slashSound:Play()
  46.         end
  47.     end
  48. end
  49.  
  50. if AxeTool:IsA("Tool") then
  51.     AxeTool.Activated:Connect(playChopAnimation)
  52.     AxeTool.Unequipped:Connect(resetAnimationState)
  53. end
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment