local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local player = Players.LocalPlayer local hitId = "rbxassetid://54584713" -- the swing animation, is replacable and supports r15 or r6 local hitSpeed = 1.0 -- speed of the animation i suppose local hitFadeTime = 0.1 -- how smooth can the animation end local hitPriority = Enum.AnimationPriority.Action -- layers of animation, now above idle and walk (and run, and jump, and fall) local hitAnim = Instance.new("Animation") hitAnim.AnimationId = hitId local currentHitTrack = nil local function playHit() local char = player.Character if not char or not currentHitTrack then return end if currentHitTrack.IsPlaying then currentHitTrack.TimePosition = 0 else currentHitTrack:Play(hitFadeTime, 1, hitSpeed) end end UserInputService.InputBegan:Connect(function(input, gameProcessed) if gameProcessed then return end if input.KeyCode == Enum.KeyCode.Z then playHit() end end) local function setupCharacter(character) if currentHitTrack then if currentHitTrack.IsPlaying then currentHitTrack:Stop(0) end currentHitTrack:Destroy() currentHitTrack = nil end local humanoid = character:WaitForChild("Humanoid", 5) if not humanoid then return end local animator = humanoid:FindFirstChildOfClass("Animator") if not animator then animator = Instance.new("Animator", humanoid) end currentHitTrack = animator:LoadAnimation(hitAnim) currentHitTrack.Looped = false currentHitTrack.Priority = hitPriority end player.CharacterAdded:Connect(setupCharacter) if player.Character then task.spawn(setupCharacter, player.Character) end