Well my animation key binding works all good but I want to know how to let the animation stop when my character moves.

My script:

local animations = {

			[Enum.KeyCode.Z] = 580461455,
			[Enum.KeyCode.X] = 625892060,
			
}

repeat wait() until game.Players.LocalPlayer; local player = game.Players.LocalPlayer repeat wait() until player.Character; local character = player.Character local currentAnimId,currentPlaying = '',nil local humanoid = character:FindFirstChild('Humanoid') local uis = game:GetService('UserInputService')

uis.InputBegan:connect(function(input,gpe) if not gpe then if animations[input.KeyCode] ~= nil then local animId = 'http://www.roblox.com/Asset?ID=' .. animations[input.KeyCode] if animId ~= currentAnimId then if humanoid ~= nil and humanoid.Health > 0 then if currentPlaying ~= nil and currentPlaying.IsPlaying then currentPlaying:Stop() end local animation = Instance.new('Animation'); animation.AnimationId = animId local animTrack = humanoid:LoadAnimation(animation); currentPlaying = animTrack animTrack:Play(0.100000001,1,1) end end end end end)

2 comments

1
0

well i don't know how to fix the code block