I’ve been trying to figure out how to play a gun walk animation when the player is moving and stop it when he is not moving. This has been very difficult, I’ve tried different methods like UserInputBegan and UserinputEnded but that glitched the animation, and I tried Character.PrimaryPart.LinearVelocity.Magnitude but that was also glitchy. I just want to know a simple way I can detect if the character is moving or not.
It still doesn’t work when I try to play the animation with it
It printed “Stopped” Once and then it stopped working
if input.KeyCode == Enum.KeyCode.W and IsEquipped.Value == true then
if Humanoid.MoveDirection.Magnitude > 0 then -- Is the character walking?
gunWalkAnim:Play()
print("Test")
else
gunWalkAnim:Stop()
print("Stopped")
end
end
```
When you made the animation was it looped? If so, make it so its not looped.
Yeah it is a looped walk animation that plays smoothly. If I unloop it wont it stop after the first time?
I am not good when it comes to animation but try seeing what it does when you untick looped and make sure to overwrite it so it makes a change.
I recorded a video of the problem. It seems like it sort of working but the animation is not being played all the way
Interesting. I remember having this issue once. Sorry but I’m not too sure, I don’t have enough knowledge when it comes to animating but I am sure someone else may be able to assist.
Alright its fine dont worry about it.
Did it print Test ? Or everytime is just “Stopped”
Actually, one last thing, maybe set the looped value to true when the character is walking and then set it to false when the character is not?
Is the animation made by you ?
if no, try playing in Roblox Player, it might work there
This is not the best way to do it, you can instead use this,
game.Player.LocalPlayer.Character.Humanoid.StateChanged:Connect(function()
if IsEquipped.Value then
if Humanoid.MoveDirection.Magnitude > 0 then -- Is the character walking?
gunWalkAnim:Play()
print("Test")
else
gunWalkAnim:Stop()
print("Stopped")
end
end
end)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.