I Just did a script like this but when i walk and click mouse button, i want to stop the walk animation and play the sword animation and when its finished, i want to play walk and stop sword. How can i do this?
local CanAttack = true
local player = game:GetService("Players").LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
script.Parent.Equipped:Connect(function()
local idle = Humanoid:LoadAnimation(script.Idle)
local walk = Humanoid:LoadAnimation(script.Walk)
Humanoid.Running:Connect(function(speed)
if speed > 0 then
idle:Stop()
walk:Play()
elseif speed == 0 then
idle:Play()
walk:Stop()
end
end)
end)
script.Parent.Activated:Connect(function()
local clone = game.Workspace.Anims.KatanaAttack:Clone()
clone.Parent = script.Parent.anims
game.Workspace.Anims.KatanaAttack:Destroy()
local attack = player.Character.Humanoid:LoadAnimation(script.KatanaAttack)
if CanAttack == true then
attack:Play()
clone.Parent = script.Parent
wait(1)
attack:Stop()
clone.Parent = game.Workspace.Anims
end
wait(1)
end)

4 comments
Yeah, everything is fixed. Thanks. But now, sometimes my walking animation broking. Can you tell me another way to active the walk animation? Any smooth way.
Honestly, I don't know, sorry! I would appreciate if you accepted or upvoted my answer, though.
Then i have to ask it on another question :D Have a great day.
Thank you! I am just trying to get my rank above contributor so any rep helps