How To Add A reload Animation On my Script?

Hi, I’m new to scripting, and I’m still learning to. I have decided to watch some YouTube tutorials on how to make a gun. I want something that when you ran out of bullets, a reload animation will fire then load out the gun.

This is my script(It’s inside a local script under my tool/gun):

local tool = script.Parent

local anim = Instance.new(“Animation”)

anim.AnimationId = “rbxassetid://6344330952” --shoot animation

local track

tool.Activated:Connect(function()

track = script.Parent.Parent.Humanoid:LoadAnimation(anim)

track.Looped = false

track:play()

end)

tool.Unequipped:Connect(function()

if track then

track:Stop()

end

end)

(The script looks kinda messed up here, but you get the idea. I’m new here at the devforum, so I’m not sure if I put this on the right category)

One thing I have noticed is when you create the Animation object you don’t specify the parent. That can cause problems. Just add a line under the anim variable and say anim.Parent = tool

1 Like