So im trying to make a weapon grip. I am using a handle for this and i am using R15. It equips perfectly fine with the animation but the animation wont stop if i unequip it. Additionally after a few minutes i get this error
and half the time my walk animation stops working. why half???

This is my code, i have 2 scripts a local and script. I just copied it in each. lol ik that is dumb but i didnt feel like coming up with a better solution
local Playing = false
local animation = Instance.new(“Animation”)
animation.AnimationId = “rbxassetid://5565088775” – your id here
script.Parent.Equipped:Connect(function()
Playing = true
end)
script.Parent.Unequipped:Connect(function()
Playing = false
end)
while wait(.1) do
if Playing then
local Humanoid = script.Parent.Parent:WaitForChild("Humanoid", 5)
local animTrack = Humanoid:LoadAnimation(animation)
animTrack.Priority = Enum.AnimationPriority.Idle
animTrack:Play()
end
end
1 Like
First, you can not set an animation priority from a script. You need to set it when you edit the animation, and the main error is that is an animation track playing already, just stop it right before you play the other.
Im trying to overlay it ontop of the default tool holding. Not trying to play two animations.
The problem is that you are loading animation every .1 seconds, only do it once. Same with the humanoid.
1 Like
Thanks, this helped a lot!!!
Just one question I cant seem to figure out how to stop it when i unequip the tool. Do you know how to?
animationTrack:Stop()
Try doing these variables before the events.
I did this, i dont seem to get any errors but it wont stop playing either
local Playing = false
local animTrack = nil
local animation = Instance.new(“Animation”)
animation.AnimationId = “rbxassetid://5565088775” – your id here
script.Parent.Equipped:Connect(function()
local Humanoid = script.Parent.Parent:WaitForChild(“Humanoid”, 5)
animTrack = Humanoid:LoadAnimation(animation)
animTrack.Priority = Enum.AnimationPriority.Idle
animTrack:Play()
end)
script.Parent.Unequipped:Connect(function()
animTrack:Stop()
end)
I really dont know how to help there, maybe you can load animation before?
Ok, i got it to work! thank you for the help!