I’m making a gun system and I need to make it so that you hold guns with two hands and what happens is that it plays when you the gun but then when you walk, it stops. Here is a sample of my code:
tool.Equipped:Connect(function()
local character = player.Character or player.Character:Wait()
local hum = character:WaitForChild("Humanoid")
local Animator = hum:WaitForChild("Animator")
local holdAnimation = Instance.new("Animation")
holdAnimation.AnimationId = "rbxassetid://6977809658"
local holdAnimationTrack = Animator:LoadAnimation(holdAnimation)
print("Animation Loaded")
holdAnimationTrack.Priority = Enum.AnimationPriority.Movement
holdAnimationTrack.Looped = true
holdAnimationTrack:Play()
end)
Personally, whenever I try to change the properties of animations through a script, it would work only 1/4 of the time. However, what I’ve done to fix this was that I set the property called “Looped” set to true before I uploaded my animation.
When you export through moon animator/roblox’s default animator, you will result with a blue square.
Click the square, and in the properties, set “Looped” to true.
Right click the square, and click save to Roblox. Upload it, and it will be looped.
Also remember to make your priority different depending on what animations you want to play over it/animations you don’t want