So I previously had a bug where my animtrack wasnt stopping the animations when I unequipped my tool so I changed my code so there were seperate animTracks for each animation but now my gun fires multiple bullets at once
Revolver.Activated:Connect(function()
local startPos = Revolver.Handle.CFrame.Position
local endPos = Mouse.Hit.Position
if canShoot and ammo > 0 then
IdleTrack:Stop()
EquipTrack:Stop()
ReloadTrack:Stop()
canShoot = false
ShootTrack:Play()
ShootTrack:GetMarkerReachedSignal("Fire"):Connect(function()
ShootSound:Play()
ammo -= 1
print(ammo)
canReload = true
ShootEvent:FireServer(startPos, endPos, MaxDistance)
end)
ShootTrack.Stopped:Wait()
canShoot = true
IdleTrack:Play()
end
end)
If anyone knows why please let me know! (and optionally if you know a fix on why my animations didn’t stop playing when I unequipped my gun, that would be helpful too)
The reason why your gun is firing multiple bullets is because of how you are handling the ShootTrack:GetMarkerReachedSignal("Fire"):Connect(function() inside of your Revolved.Activated function.
Since you have ShootTrack:GetMarkerReachedSignal("Fire"):Connect(function() inside of this function, every time you click to shoot, it is adding a new connection to the "Fire" marker. ROBLOX isn’t automatically cleaning up your old connections, so each time the animation hits that "Fire" marker, all previous connections are also firing - which is causing multiple bullets to be shot at once. This aligns with what you have shown in the video too.
You should move the .Connect call outside the Activated function so that it runs only once when the script starts. That way, only a single connection exists regardless of how many times the gun is fired.
If you need to access dynamic values like startPos, endPos, or MaxDistance, you can store those in variables just before playing the animation, or use function arguments to pass them in.