Automatic Gun Shooting Script

I’m trying to make an uzi auto script which is basically you hold down the mouse to shoot up to 30 bullets before reloading. Currently what I have right now is an animation track that is played on a loop when the mouse is pressed down. The animation track has a keyframe in which a remote event is fired to the server to check if the player hit anything. When the player lets go of the mouse button, the animation track stops.

Should I used a loop instead that turns on when the mouse button is down or is animation track better? The reason I was using animation track was because to avoid loops and just have the animation track go back to starting position when its played all the way through.



Make the gun continue until the mouse button is up
Mouse.Button1Up:Connect(function() etc…
Edit: Remember to add a wait.