I have a game that when im grabbing a player with a knife (as a hostage), i change my idle anim using this function:
(Events is just a table like “local Events = {}”)
if not walktrack.IsPlaying then
for i,v in pairs(humanoid.Animator:GetPlayingAnimationTracks()) do
if v.Animation.Name == "Idle" then
v:Stop()
end
end
idletrack:Play()
end
if not idletrack.IsPlaying then
for i,v in pairs(humanoid.Animator:GetPlayingAnimationTracks()) do
if v.Animation.Name == "Walk" then
v:Stop()
end
end
walktrack:Play()
end
and then i got this function to detect if im walking to stop the idle track:
table.insert(events,humanoid.Running:Connect(function(speed)
if humanoid.WalkSpeed < 20 and speed > 1 then
idletrack:Stop()
if not walktrack.IsPlaying then
walktrack:Play()
walktrack:AdjustSpeed(1)
end
else
walktrack:Stop()
if not idletrack.IsPlaying then
idletrack:Play()
end
end
end))
there is also a funciton that when i let go of a player, it changes my player stat from None to “Grabbed” indicating that i grabbed an opponent and that i should run the code to change my idle anim
but the problem is, is that if im walking and at the same time let go of an opponent, my idle track gets stuck like this:
https://gyazo.com/59807be437a3fabcb3b356b8f6a89164