Gun animations help

After unequiping the firearm, the animation remains and won’t go away, any help?

local UserInputService = game:GetService(“UserInputService”)
local InitialSensitivity = UserInputService.MouseDeltaSensitivity
local TweeningService = game:GetService(“TweenService”)
local Tool = script.Parent
local Handle = Tool:WaitForChild(“Handle”)
local Player = game:GetService(“Players”).LocalPlayer
local Mouse = Player:GetMouse()
local Camera = workspace.CurrentCamera
local Character = workspace:WaitForChild(Player.Name)
local Humanoid = Character:WaitForChild(“Humanoid”)
local VisualizeBullet = game:GetService(“ReplicatedStorage”):WaitForChild(“VisualizeBullet”)
local Module = require(Tool:WaitForChild(“Setting”))
local GunScript_Server = Tool:WaitForChild(“GunScript_Server”)
local ChangeMagAndAmmo = GunScript_Server:WaitForChild(“ChangeMagAndAmmo”)
local InflictTarget = GunScript_Server:WaitForChild(“InflictTarget”)
local MagValue = GunScript_Server:WaitForChild(“Mag”)
local AmmoValue = GunScript_Server:WaitForChild(“Ammo”)
local GUI = script:WaitForChild(“GunGUI”)
local CrosshairModule = require(GUI:WaitForChild(“CrosshairModule”))
local CameraModule = require(GUI:WaitForChild(“CameraModule”))
local IdleAnim
local FireAnim
local ReloadAnim
local ShotgunClipinAnim
local HoldDownAnim
local EquippedAnim
local Grip2
local Handle2
local HandleToFire = Handle


–= Tween Functions =–

– tween information(Don’t edit this one or else…)

    local TweenInformation = TweenInfo.new(
      Module.TweenLength, --tween length
      Module.EasingStyle, --easing Style
      Module.EasingDirection, --easing Direction
      0, --repitition time
      false, --reverse?
      0 --delay				
    )

– tween information[No aim down](Don’t edit this one or else…)

    local TweenInformationNAD = TweenInfo.new(
      Module.TweenLengthNAD, --tween length
      Module.EasingStyleNAD, --easing Style
      Module.EasingDirectionNAD, --easing Direction
      0, --repitition time
      false, --reverse?
      0 --delay				
    )

– tween information[Hitmarker](Don’t edit this one or else…)

    local TweenInformationHIT = TweenInfo.new(
      Module.HitmarkerFadeTime, --tween length
      Enum.EasingStyle.Linear, --easing Style
      Enum.EasingDirection.Out, --easing Direction
      0, --repitition time
      false, --reverse?
      0 --delay				
    )

– aiming

    local FOVAiming = {
      FieldOfView = Module.FieldOfViewS
    }

    local tweenAim = TweeningService:Create(Camera,TweenInformation,FOVAiming)

– ironsighting

    local FOVSighting = {
      FieldOfView = Module.FieldOfViewIS
    }

    local tweenSight = TweeningService:Create(Camera,TweenInformation,FOVSighting)

– non-aiming

    local FOVNonAiming = {
      FieldOfView = 70
    }

    local tweenNoAim = TweeningService:Create(Camera,TweenInformationNAD,FOVNonAiming)

if Module.DualEnabled then
Handle2 = Tool:WaitForChild(“Handle2”,2)
if Handle2 == nil and Module.DualEnabled then error("“Dual” setting is enabled but “Handle2” is missing!") end
end

local StanceSway = 1
local Equipped = false
local Enabled = true
local Down = false
local HoldDown = false
local Reloading = false
local AimDown = false
local Mag = MagValue.Value
local Ammo = AmmoValue.Value
local MaxAmmo = Module.MaxAmmo
local PiercedHumanoid = {}

if Module.IdleAnimationID ~= nil or Module.DualEnabled then
IdleAnim = Tool:WaitForChild(“IdleAnim”)
IdleAnim = Humanoid:LoadAnimation(IdleAnim)
end
if Module.FireAnimationID ~= nil then
FireAnim = Tool:WaitForChild(“FireAnim”)
FireAnim = Humanoid:LoadAnimation(FireAnim)
end
if Module.ReloadAnimationID ~= nil then
ReloadAnim = Tool:WaitForChild(“ReloadAnim”)
ReloadAnim = Humanoid:LoadAnimation(ReloadAnim)
end
if Module.ShotgunClipinAnimationID ~= nil then
ShotgunClipinAnim = Tool:WaitForChild(“ShotgunClipinAnim”)
ShotgunClipinAnim = Humanoid:LoadAnimation(ShotgunClipinAnim)
end
if Module.HoldDownAnimationID ~= nil then
HoldDownAnim = Tool:WaitForChild(“HoldDownAnim”)
HoldDownAnim = Humanoid:LoadAnimation(HoldDownAnim)
end
if Module.HideAnimationID ~= nil then
HideAnim = Tool:WaitForChild(“HideAnim”)
HideAnim = Humanoid:LoadAnimation(HideAnim)
end
if Module.EquippedAnimationID ~= nil then
EquippedAnim = Tool:WaitForChild(“EquippedAnim”)
EquippedAnim = Humanoid:LoadAnimation(EquippedAnim)
end

function wait(TimeToWait)
if TimeToWait ~= nil then
local TotalTime = 0
TotalTime = TotalTime + game:GetService(“RunService”).Heartbeat:wait()
while TotalTime < TimeToWait do
TotalTime = TotalTime + game:GetService(“RunService”).Heartbeat:wait()
end
else
game:GetService(“RunService”).Heartbeat:wait()
end
end

function RayCast(Start,Direction,Range,Ignore)
local Hit,EndPos,Normal = game.workspace:FindPartOnRay(Ray.new(Start,DirectionRange),Ignore)
if Hit then
if (Hit.Transparency > 0.75
or Hit.Name == “Handle”
or Hit.Name == “Effect”
or Hit.Name == “Bullet”
or Hit.Name == “Laser”
or string.lower(Hit.Name) == “water”
or Hit.Name == “Rail”
or Hit.Name == “Arrow”
or (Hit.Parent:FindFirstChild(“Humanoid”) and Hit.Parent.Humanoid.Health == 0)
or (Hit.Parent:FindFirstChild(“Humanoid”) and Hit.Parent:FindFirstChild(“TEAM”) and TEAM and Hit.Parent.TEAM.Value == TEAM.Value))
or (Hit.Parent:FindFirstChild(“Humanoid”) and PiercedHumanoid[Hit.Parent.Humanoid]) then
Hit,EndPos,Normal = RayCast(EndPos+(Direction
.01),Direction,Range-((Start-EndPos).magnitude),Ignore)
end
end
return Hit,EndPos,Normal
end

function RAND(Min, Max, Accuracy)
local Inverse = 1 / (Accuracy or 1)
return (math.random(Min * Inverse, Max * Inverse) / Inverse)
end

function CreateHitmarker()
if Module.HitmarkerEnabled then
GUI.Crosshair.Hitmarker.ImageTransparency = 0
local hitmarker = {
ImageTransparency = 1
}
local tweenFade = TweeningService:Create(GUI.Crosshair.Hitmarker,TweenInformationHIT,hitmarker)
tweenFade:Play()
local markersound = GUI.Crosshair.MarkerSound:Clone()
markersound.Parent = Player.PlayerGui
markersound:Play()
game:GetService(“Debris”):addItem(markersound,markersound.TimeLength)
end
end

function EjectShell(ShootingHandle)
if Module.BulletShellEnabled then
local ShellPos = (ShootingHandle.CFrame * CFrame.new(Module.BulletShellOffset.X,Module.BulletShellOffset.Y,Module.BulletShellOffset.Z)).p
local Chamber = Instance.new(“Part”)
Chamber.Name = “Bullet”
Chamber.Size = Vector3.new(0.01,0.01,0.01)
Chamber.Transparency = 1
Chamber.Anchored = false
Chamber.CanCollide = true
Chamber.TopSurface = Enum.SurfaceType.SmoothNoOutlines
Chamber.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
local Weld = Instance.new(“Weld”,Chamber)
Weld.Part0 = ShootingHandle
Weld.Part1 = Chamber
Weld.C0 = CFrame.new(Module.BulletShellOffset.X,Module.BulletShellOffset.Y,Module.BulletShellOffset.Z)
Chamber.Position = ShellPos
Chamber.Parent = game.Workspace

  Tool.DropObject:FireServer("DropShell",Chamber.CFrame)
  game.Debris:AddItem(Chamber,20000)	

end
end

function RecoilCamera()
if Module.CameraRecoilingEnabled then
local CurrentRecoil = Module.Recoil*(AimDown and 1-Module.RecoilRedution or 1)
local RecoilX = math.rad(CurrentRecoil * RAND(Module.AngleX_Min, Module.AngleX_Max, Module.Accuracy)) * StanceSway
local RecoilY = math.rad(CurrentRecoil * RAND(Module.AngleY_Min, Module.AngleY_Max, Module.Accuracy)) * StanceSway
local RecoilZ = math.rad(CurrentRecoil * RAND(Module.AngleZ_Min, Module.AngleZ_Max, Module.Accuracy)) * StanceSway
CameraModule:accelerate(RecoilX,RecoilY,RecoilZ)
delay(0.05, function()
CameraModule:accelerateXY(-RecoilX,-RecoilY)
end)
end
end

function Fire(ShootingHandle)
local PierceAvailable = Module.Piercing
PiercedHumanoid = {}
if FireAnim then FireAnim:Play(nil,nil,Module.FireAnimationSpeed) end
if not ShootingHandle.FireSound.Playing or not ShootingHandle.FireSound.Looped then ShootingHandle.FireSound:Play() script.Parent.Handle.BoltBack:Play() wait(0.1) script.Parent.Handle.BoltForward:Play() wait(0.0001) end
local Start = (Character.Head.CFrame * CFrame.new(0,1.5,0)).p–(Handle.CFrame * CFrame.new(Module.MuzzleOffset.X,Module.MuzzleOffset.Y,Module.MuzzleOffset.Z)).p
local Spread = Module.Spread*(AimDown and 1-Module.SpreadRedutionIS and 1-Module.SpreadRedutionS or 1)
local Direction = (CFrame.new(Start,Mouse.Hit.p) * CFrame.Angles(math.rad(-Spread+(math.random()(Spread2))),math.rad(-Spread+(math.random()(Spread2))),0)).lookVector
while PierceAvailable >= 0 do
local Hit,EndPos,Normal = RayCast(Start,Direction,Module.Range,Character)
if not Module.ExplosiveEnabled then
if Hit and Hit.Parent then
local TargetHumanoid = Hit.Parent:FindFirstChild(“Humanoid”)
local TargetTorso = Hit.Parent:FindFirstChild(“Head”)
local Jam = math.random(1,100000)
if Jam < 2 then
script.Parent.DropObject:FireServer(“Jam”)
end
–local TargetTEAM = Hit.Parent:FindFirstChild(“TEAM”)
if TargetHumanoid and TargetHumanoid.Health > 0 and TargetTorso then
–if TargetTEAM and TargetTEAM.Value ~= TEAM.Value then
InflictTarget:FireServer(TargetHumanoid,
TargetTorso,
(Hit.Name == “Head” and Module.HeadshotEnabled) and Module.BaseDamage * Module.HeadshotDamageMultiplier or Module.BaseDamage,
Direction,
Module.Knockback,
Module.Lifesteal,
Module.FlamingBullet)
PiercedHumanoid[TargetHumanoid] = true
CreateHitmarker()

                    Player.PlayerScripts.BulletVisualizerScript.BloodVisualizer:Fire(nil,ShootingHandle,
                                                                             Hit,
                                                                               EndPos,
                                                                               Normal,
                                                                               script.BloodEffect,
                                                                               Module.HitCharSndIDs[math.random(1,#Module.HitCharSndIDs)],
                                                                               Module.HitCharSndPitch,
                                                                               Module.BloodEnabled)
                    game:GetService("ReplicatedStorage").VisualizeBlood:FireServer(ShootingHandle,
                                                                             Hit,
                                                                               EndPos,
                                                                               Normal,
                                                                               script.BloodEffect,
                                                                               Module.HitCharSndIDs[math.random(1,#Module.HitCharSndIDs)],
                                                                               Module.HitCharSndPitch,
                                                                               Module.BloodEnabled)	
  			--end
  		else
  			PierceAvailable = 0
                    Player.PlayerScripts.BulletVisualizerScript.ImpactVisualizer:Fire(nil,ShootingHandle,
                                                                             Hit,
                                                                               EndPos,
                                                                               Normal,
                                                                               script.HitEffect,
                                                                               Module.HitSoundIDs[math.random(1,#Module.HitSoundIDs)],
                                                                               Module.HitSoundPitch,
                                                                               Module.HitEffectEnabled,
                                                                               {Module.BulletHoleEnabled,Module.BulletHoleSize,Module.BulletHoleTexture[math.random(1,#Module.BulletHoleTexture)],Module.BulletHoleVisibleTime,Module.BulletHoleFadeTime},
                                                                               Module.CustomHitEffect)
                    game:GetService("ReplicatedStorage").VisualizeImpact:FireServer(ShootingHandle,
                                                                             Hit,
                                                                               EndPos,
                                                                               Normal,
                                                                               script.HitEffect,
                                                                               Module.HitSoundIDs[math.random(1,#Module.HitSoundIDs)],
                                                                               Module.HitSoundPitch,
                                                                               Module.HitEffectEnabled,
                                                                               {Module.BulletHoleEnabled,Module.BulletHoleSize,Module.BulletHoleTexture[math.random(1,#Module.BulletHoleTexture)],Module.BulletHoleVisibleTime,Module.BulletHoleFadeTime},
                                                                               Module.CustomHitEffect)
  		end
  	end

  else
  	local Explosion = Instance.new("Explosion")
  	Explosion.BlastRadius = Module.Radius
  	Explosion.BlastPressure = 0
  	Explosion.Position = EndPos
  	Explosion.Parent = workspace.CurrentCamera
  	Explosion.Hit:connect(function(Hit)
  		if Hit and Hit.Parent and Hit.Name == "Head" then
  			local TargetHumanoid = Hit.Parent:FindFirstChild("Humanoid")
  			local TargetTorso = Hit.Parent:FindFirstChild("Head")
  			--local TargetTEAM = Hit.Parent:FindFirstChild("TEAM")
  			if TargetHumanoid and TargetHumanoid.Health > 0 and TargetTorso then
  				--if TargetTEAM and TargetTEAM.Value ~= TEAM.Value then
  					InflictTarget:FireServer(TargetHumanoid,
  											TargetTorso,
  											(Hit.Name == "Head" and Module.HeadshotEnabled) and Module.BaseDamage * Module.HeadshotDamageMultiplier or Module.BaseDamage,
  											Direction,
  											Module.Knockback,
  											Module.Lifesteal,
  											Module.FlamingBullet)
                    CreateHitmarker()					
  				--end
  			end
  		end
  	end)
  	PierceAvailable = 0
  end
  PierceAvailable = Hit and (PierceAvailable - 1) or -1
  Player.PlayerScripts.BulletVisualizerScript.BulletVisualizer:Fire(nil,ShootingHandle,
  															Module.BulletOffset,
  															EndPos,
  															{Module.ExplosiveEnabled,Module.BlastRadius,Module.BlastPressure},
  															{Module.BulletSpeed,Module.BulletSize,Module.BulletColor,Module.BulletTransparency,Module.BulletMaterial,Module.FadeTime,Module.BulletShape},
  															false,
  															PierceAvailable == -1 and Module.VisualizerEnabled or false,
  															{Module.WhizSoundEnabled,Module.WhizSoundID,Module.WhizSoundVolume,Module.WhizSoundPitch})
  game:GetService("ReplicatedStorage").VisualizeBullet:FireServer(ShootingHandle,
  												Module.BulletOffset,
  												EndPos,
  												{Module.ExplosiveEnabled,Module.BlastRadius,Module.BlastPressure},
  												{Module.BulletSpeed,Module.BulletSize,Module.BulletColor,Module.BulletTransparency,Module.BulletMaterial,Module.FadeTime,Module.BulletShape},
  												true,
  												PierceAvailable == -1 and Module.VisualizerEnabled or false,
  												{Module.WhizSoundEnabled,Module.WhizSoundID,Module.WhizSoundVolume,Module.WhizSoundPitch})
  Start = EndPos + (Direction*0.01)

end
end

function Reload()
local Event = script.Parent.DropObject
if Enabled and not Reloading and (Ammo > 0 or not Module.LimitedAmmoEnabled) and Mag < Module.AmmoPerMag then
Reloading = true
if AimDown then
tweenNoAim:Play()
CrosshairModule:setcrossscale(1)
–[[local GUI = game:GetService(“Players”).LocalPlayer.PlayerGui:FindFirstChild(“ZoomGui”)
if GUI then GUI:Destroy() end]]
GUI.Scope.Visible = false
game:GetService(“Players”).LocalPlayer.CameraMode = Enum.CameraMode.Classic
UserInputService.MouseDeltaSensitivity = InitialSensitivity
AimDown = false
end
script.Parent.DropObject:FireServer(“DropMag”)
Handle.MagOut:Play()
delay(.32, function()
Handle.MagIn:Play()
end)
UpdateGUI()
if Module.ShotgunReload then
for i = 1,(Module.AmmoPerMag - Mag) do
if ShotgunClipinAnim then ShotgunClipinAnim:Play(nil,nil,Module.ShotgunClipinAnimationSpeed) end
Handle.ShotgunClipin:Play()
wait(Module.ShellClipinSpeed)
end
end
if ReloadAnim then ReloadAnim:Play(nil,nil,Module.ReloadAnimationSpeed) end
wait(Module.ReloadTime)
if Module.LimitedAmmoEnabled then
local ammoToUse = math.min(Module.AmmoPerMag - Mag, Ammo)
Mag = Mag + ammoToUse
Ammo = Ammo - ammoToUse
else
Mag = Module.AmmoPerMag
end
ChangeMagAndAmmo:FireServer(Mag,Ammo)
Reloading = false
UpdateGUI()
end
end

function UpdateGUI()
GUI.Frame.Mag.Fill:TweenSizeAndPosition(UDim2.new(Mag/Module.AmmoPerMag,0,1,0), UDim2.new(0,0,0,0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.25, true)
GUI.Frame.Ammo.Fill:TweenSizeAndPosition(UDim2.new(Ammo/Module.MaxAmmo,0,1,0), UDim2.new(0,0,0,0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.25, true)
GUI.Frame.Mag.Current.Text = Mag
GUI.Frame.Mag.Max.Text = Module.AmmoPerMag
GUI.Frame.Ammo.Current.Text = Ammo
GUI.Frame.Ammo.Max.Text = Module.MaxAmmo

GUI.Frame.Mag.Current.Visible = not Reloading
GUI.Frame.Mag.Max.Visible = not Reloading
GUI.Frame.Mag.Frame.Visible = not Reloading
GUI.Frame.Mag.Reloading.Visible = Reloading

GUI.Frame.Ammo.Current.Visible = not (Ammo <= 0)
GUI.Frame.Ammo.Max.Visible = not (Ammo <= 0)
GUI.Frame.Ammo.Frame.Visible = not (Ammo <= 0)
GUI.Frame.Ammo.NoMoreAmmo.Visible = (Ammo <= 0)

GUI.Frame.Ammo.Visible = Module.LimitedAmmoEnabled
GUI.Frame.Size = Module.LimitedAmmoEnabled and UDim2.new(0,250,0,100) or UDim2.new(0,250,0,55)
GUI.Frame.Position = Module.LimitedAmmoEnabled and UDim2.new(1,-260,1,-110)or UDim2.new(1,-260,1,-65)
GUI.MobileButtons.Visible = UserInputService.TouchEnabled --For mobile version
GUI.MobileButtons.AimButton.Visible = Module.SniperEnabled or Module.IronsightEnabled
GUI.MobileButtons.HoldDownButton.Visible = Module.HoldDownEnabled
end


–= Mobile Functions =–

– aiming

GUI.MobileButtons.AimButton.MouseButton1Click:connect(function()
if not Reloading and not HoldDown and AimDown == false and Equipped == true and Module.IronsightEnabled and (Character.Head.Position - Camera.CoordinateFrame.p).magnitude <= 1 then
tweenSight:Play()
CrosshairModule:setcrossscale(Module.CrossScaleIS)
–[[local GUI = game:GetService(“Players”).LocalPlayer.PlayerGui:FindFirstChild(“ZoomGui”) or Tool.ZoomGui:Clone()
GUI.Parent = game:GetService(“Players”).LocalPlayer.PlayerGui]]
–GUI.Scope.Visible = true
game:GetService(“Players”).LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
UserInputService.MouseDeltaSensitivity = InitialSensitivity * Module.MouseSensitiveIS
AimDown = true
elseif not Reloading and not HoldDown and AimDown == false and Equipped == true and Module.SniperEnabled and (Character.Head.Position - Camera.CoordinateFrame.p).magnitude <= 1 then
tweenAim:Play()
CrosshairModule:setcrossscale(Module.CrossScaleS)
–[[local GUI = game:GetService(“Players”).LocalPlayer.PlayerGui:FindFirstChild(“ZoomGui”) or Tool.ZoomGui:Clone()
GUI.Parent = game:GetService(“Players”).LocalPlayer.PlayerGui]]
local zoomsound = GUI.Scope.ZoomSound:Clone()
zoomsound.Parent = Player.PlayerGui
zoomsound:Play()
GUI.Scope.Visible = true
game:GetService(“Players”).LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
UserInputService.MouseDeltaSensitivity = InitialSensitivity * Module.MouseSensitiveS
AimDown = true
game:GetService(“Debris”):addItem(zoomsound,5)
else
tweenNoAim:Play()
CrosshairModule:setcrossscale(1)
–[[local GUI = game:GetService(“Players”).LocalPlayer.PlayerGui:FindFirstChild(“ZoomGui”)
if GUI then GUI:Destroy() end]]
GUI.Scope.Visible = false
game:GetService(“Players”).LocalPlayer.CameraMode = Enum.CameraMode.Classic
UserInputService.MouseDeltaSensitivity = InitialSensitivity
AimDown = false
end
end)

– holding down gun

GUI.MobileButtons.HoldDownButton.MouseButton1Click:connect(function()
if not Reloading and not HoldDown and Module.HoldDownEnabled then
HoldDown = true
IdleAnim:Stop()
if HoldDownAnim then HoldDownAnim:Play(nil,nil,Module.HoldDownAnimationSpeed) end
if AimDown then
tweenNoAim:Play()
CrosshairModule:setcrossscale(1)
–[[local GUI = game:GetService(“Players”).LocalPlayer.PlayerGui:FindFirstChild(“ZoomGui”)
if GUI then GUI:Destroy() end]]
GUI.Scope.Visible = false
game:GetService(“Players”).LocalPlayer.CameraMode = Enum.CameraMode.Classic
UserInputService.MouseDeltaSensitivity = InitialSensitivity
AimDown = false
end
else
HoldDown = false
IdleAnim:Play(nil,nil,Module.IdleAnimationSpeed)
if HoldDownAnim then HoldDownAnim:Stop() end
end
end)

– reloading

GUI.MobileButtons.ReloadButton.MouseButton1Click:connect(function()
Reload()
end)


Mouse.Button1Down:connect(function()
if Equipped then
local a = script.Parent.ReturnStuff:InvokeServer(“HasMagazine”)
if not a then script.Parent.Handle.Click:Play() return end
else
return
end
Down = true
local IsChargedShot = false
if Equipped and Enabled and Down and not Reloading and not HoldDown and Mag > 0 and Humanoid.Health > 0 then
Enabled = false

  script.Parent.SmokePart.Smoke.Enabled = true
  delay(0.1,function()
  script.Parent.SmokePart.Smoke.Enabled = false			
  end)
  EjectShell(HandleToFire)
  if Module.ChargedShotEnabled then
  	if HandleToFire:FindFirstChild("ChargeSound") then HandleToFire.ChargeSound:Play() end
  	wait(Module.ChargingTime)
  	IsChargedShot = true
  end
  if Module.MinigunEnabled then
  	if HandleToFire:FindFirstChild("WindUp") then HandleToFire.WindUp:Play() end
  	wait(Module.DelayBeforeFiring)
  end
  while Equipped and not Reloading and not HoldDown and (Down or IsChargedShot) and Mag > 0 and Humanoid.Health > 0 do
  	IsChargedShot = false
  	
  Player.PlayerScripts.BulletVisualizerScript.MuzzleVisualizer:Fire(nil,HandleToFire,
  															Module.MuzzleOffset,
  															script.MuzzleEffect,
  															{Module.MuzzleLightEnabled,Module.LightOffset,Module.LightBrightness,Module.LightColor,Module.LightRange,Module.LightShadows,Module.VisibleTime})
  game:GetService("ReplicatedStorage").VisualizeMuzzle:FireServer(HandleToFire,
  												Module.MuzzleOffset,
  												script.MuzzleEffect,
  												{Module.MuzzleLightEnabled,Module.LightOffset,Module.LightBrightness,Module.LightColor,Module.LightRange,Module.LightShadows,Module.VisibleTime})		
  	
  	for i = 1,(Module.BurstFireEnabled and Module.BulletPerBurst or 1) do
  		spawn(RecoilCamera)
  		EjectShell(HandleToFire)
  		CrosshairModule.crossspring:accelerate(Module.CrossExpansion)		
  		for x = 1,(Module.ShotgunEnabled and Module.BulletPerShot or 1) do
  			Fire(HandleToFire)
  		end
  		Mag = Mag - 1
  		ChangeMagAndAmmo:FireServer(Mag,Ammo)
  		if Mag <= 0 then
  			script.Parent.DropObject:FireServer("SubtractAmmo")					
  		end
  		UpdateGUI()
  		if Module.BurstFireEnabled then wait(Module.BurstRate) end
  		if Mag <= 0 then break end
  	end
  	HandleToFire = (HandleToFire == Handle and Module.DualEnabled) and Handle2 or Handle
  	wait(Module.FireRate)
  	if not Module.Auto then break end
  end
  if HandleToFire.FireSound.Playing and HandleToFire.FireSound.Looped then HandleToFire.FireSound:Stop() end
  if Module.MinigunEnabled then
  	if HandleToFire:FindFirstChild("WindDown") then HandleToFire.WindDown:Play() end
  	wait(Module.DelayAfterFiring)
  end
  Enabled = true
  if Mag <= 0 then Reload() end

end
end)
Mouse.Button1Up:connect(function()
Down = false
end)

ChangeMagAndAmmo.OnClientEvent:connect(function(ChangedMag,ChangedAmmo)
Mag = ChangedMag
Ammo = ChangedAmmo
UpdateGUI()
end)
Tool.Equipped:connect(function(TempMouse)
Equipped = true
UpdateGUI()
Handle.BoltBack:Play()
delay(.1,function()
Handle.BoltForward:Play()
end)
if Module.WalkSpeedRedutionEnabled then
Humanoid.WalkSpeed = Humanoid.WalkSpeed - Module.WalkSpeedRedution
else
Humanoid.WalkSpeed = Humanoid.WalkSpeed
end
CrosshairModule:setcrosssettings(Module.CrossSize, Module.CrossSpeed, Module.CrossDamper)
UserInputService.MouseIconEnabled = true
if EquippedAnim then EquippedAnim:Play(nil,nil,Module.EquippedAnimationSpeed) end
if Module.AmmoPerClip ~= math.huge then GUI.Parent = Player.PlayerGui end
if IdleAnim then IdleAnim:Play(nil,nil,Module.IdleAnimationSpeed) end
TempMouse.KeyDown:connect(function(Key)
if string.lower(Key) == “r” then
Reload()
elseif string.lower(Key) == “l” then
script.Parent.DropObject:FireServer(“TurnFlashlight”)
elseif string.lower(Key) == “q” then
if not Reloading and not HoldDown and Module.HoldDownEnabled then
HoldDown = true
IdleAnim:Stop()
if HoldDownAnim then HoldDownAnim:Play(nil,nil,Module.HoldDownAnimationSpeed) end
if AimDown then
tweenNoAim:Play()
CrosshairModule:setcrossscale(1)
–[[local GUI = game:GetService(“Players”).LocalPlayer.PlayerGui:FindFirstChild(“ZoomGui”)
if GUI then GUI:Destroy() end]]
GUI.Scope.Visible = false
game:GetService(“Players”).LocalPlayer.CameraMode = Enum.CameraMode.Classic
UserInputService.MouseDeltaSensitivity = InitialSensitivity
AimDown = false

    	end

  	else
  		HoldDown = false
  		IdleAnim:Play(nil,nil,Module.IdleAnimationSpeed)
            if HoldDownAnim then HoldDownAnim:Stop() end
  	end
      elseif string.lower(Key) == "h" then
  	if not Reloading and not HoldDown and Module.HoldDownEnabled then
  		HoldDown = true
  		IdleAnim:Stop()
            if HideAnim then 
            HideAnim:Play(nil,nil,Module.HideAnimationSpeed) end
		    if AimDown then              
  	        tweenNoAim:Play()
  	        CrosshairModule:setcrossscale(1)
  	        --[[local GUI = game:GetService("Players").LocalPlayer.PlayerGui:FindFirstChild("ZoomGui")
  	        if GUI then GUI:Destroy() end]]
          	GUI.Scope.Visible = false
  	        game:GetService("Players").LocalPlayer.CameraMode = Enum.CameraMode.Classic
  	        UserInputService.MouseDeltaSensitivity = InitialSensitivity
  	        AimDown = false
    	end
  	else
  		HoldDown = false
  		IdleAnim:Play(nil,nil,Module.IdleAnimationSpeed)
            if HideAnim then HideAnim:Stop() end
  	end
  end

end)
Mouse.Button2Down:connect(function()
if not Reloading and not HoldDown and AimDown == false and Equipped == true and Module.IronsightEnabled and (Character.Head.Position - Camera.CoordinateFrame.p).magnitude <= 1 then
tweenSight:Play()
CrosshairModule:setcrossscale(Module.CrossScaleIS)
–[[local GUI = game:GetService(“Players”).LocalPlayer.PlayerGui:FindFirstChild(“ZoomGui”) or Tool.ZoomGui:Clone()
GUI.Parent = game:GetService(“Players”).LocalPlayer.PlayerGui]]
–GUI.Scope.Visible = true
game:GetService(“Players”).LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
UserInputService.MouseDeltaSensitivity = InitialSensitivity * Module.MouseSensitiveIS
AimDown = true
elseif not Reloading and not HoldDown and AimDown == false and Equipped == true and Module.SniperEnabled and (Character.Head.Position - Camera.CoordinateFrame.p).magnitude <= 1 then
tweenAim:Play()
CrosshairModule:setcrossscale(Module.CrossScaleS)
–[[local GUI = game:GetService(“Players”).LocalPlayer.PlayerGui:FindFirstChild(“ZoomGui”) or Tool.ZoomGui:Clone()
GUI.Parent = game:GetService(“Players”).LocalPlayer.PlayerGui]]
local zoomsound = GUI.Scope.ZoomSound:Clone()
zoomsound.Parent = Player.PlayerGui
zoomsound:Play()
GUI.Scope.Visible = true
game:GetService(“Players”).LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
UserInputService.MouseDeltaSensitivity = InitialSensitivity * Module.MouseSensitiveS
AimDown = true
game:GetService(“Debris”):addItem(zoomsound,zoomsound.TimeLength)
end
end)
Mouse.Button2Up:connect(function()
if AimDown then
tweenNoAim:Play()
CrosshairModule:setcrossscale(1)
–[[local GUI = game:GetService(“Players”).LocalPlayer.PlayerGui:FindFirstChild(“ZoomGui”)
if GUI then GUI:Destroy() end]]
GUI.Scope.Visible = false
game:GetService(“Players”).LocalPlayer.CameraMode = Enum.CameraMode.Classic
UserInputService.MouseDeltaSensitivity = InitialSensitivity
AimDown = false
end
end)
if Module.DualEnabled and not workspace.FilteringEnabled then
Handle2.CanCollide = false
local LeftArm = Tool.Parent:FindFirstChild(“Left Arm”)
local RightArm = Tool.Parent:FindFirstChild(“Right Arm”)
if RightArm then
local Grip = RightArm:WaitForChild(“RightGrip”,0.01)
if Grip then
Grip2 = Grip:Clone()
Grip2.Name = “LeftGrip”
Grip2.Part0 = LeftArm
Grip2.Part1 = Handle2
–Grip2.C1 = Grip2.C1:inverse()
Grip2.Parent = LeftArm
end
end
end
end)
Tool.Unequipped:connect(function()
HoldDown = false
Equipped = false
GUI.Parent = script
if Module.WalkSpeedRedutionEnabled then
Humanoid.WalkSpeed = Humanoid.WalkSpeed + Module.WalkSpeedRedution
else
Humanoid.WalkSpeed = Humanoid.WalkSpeed
end
UserInputService.MouseIconEnabled = true
if IdleAnim then IdleAnim:Stop() end
if HoldDownAnim then HoldDownAnim:Stop() end
if AimDown then
tweenNoAim:Play()
CrosshairModule:setcrossscale(1)
–[[local GUI = game:GetService(“Players”).LocalPlayer.PlayerGui:FindFirstChild(“ZoomGui”)
if GUI then GUI:Destroy() end]]
GUI.Scope.Visible = false
game:GetService(“Players”).LocalPlayer.CameraMode = Enum.CameraMode.Classic
UserInputService.MouseDeltaSensitivity = InitialSensitivity
AimDown = false
end
if Module.DualEnabled and not workspace.FilteringEnabled then
Handle2.CanCollide = true
if Grip2 then Grip2:Destroy() end
end
end)
Mouse.Button2Down:Connect(function()
local jam = script.Parent.Jammed.Value
if jam then
script.Parent.DropObject:FireServer(“Unjam”)
script.Parent.DropObject:FireServer(“DropShell”)
end
end)

Humanoid.Died:connect(function()
HoldDown = false
Equipped = false
GUI.Parent = script
if Module.WalkSpeedRedutionEnabled then
Humanoid.WalkSpeed = Humanoid.WalkSpeed + Module.WalkSpeedRedution
else
Humanoid.WalkSpeed = Humanoid.WalkSpeed
end
UserInputService.MouseIconEnabled = true
if IdleAnim then IdleAnim:Stop() end
if HoldDownAnim then HoldDownAnim:Stop() end
if AimDown then
tweenNoAim:Play()
CrosshairModule:setcrossscale(1)
–[[local GUI = game:GetService(“Players”).LocalPlayer.PlayerGui:FindFirstChild(“ZoomGui”)
if GUI then GUI:Destroy() end]]
GUI.Scope.Visible = false
game:GetService(“Players”).LocalPlayer.CameraMode = Enum.CameraMode.Classic
UserInputService.MouseDeltaSensitivity = InitialSensitivity
AimDown = false
end
if Module.DualEnabled and not workspace.FilteringEnabled then
Handle2.CanCollide = true
if Grip2 then Grip2:Destroy() end
end
end)

script.Parent.AncestryChanged:Connect(function()
if script.Parent.Parent.Name == “Backpack” or script.Parent.Parent.Parent == game.Workspace then
script.Parent.DropObject:FireServer(“CheckIfAmmo”)
end
end)

game:GetService(“RunService”).RenderStepped:Connect(function()
GUI.Crosshair.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
end)

1 Like

Because you’re not stopping the animation.

Also please use the correct channel next time which is #help-and-feedback:scripting-support

local Anim = Animhere

Tool.Equipped:Connect(function(mouse)
    Anim:Play()
end)

Tool.Unequipped:Connect(function()
    Anim:Stop()
end)
2 Likes

you’re not giving us the script, so we can’t help much
otherwise the answer would be whatever tpam posted

Provide us the script, we can’t really do much in terms of help on seeing which line of your code has an error.

image paste this script I just made for you [- The script has to be LocalScript -]


local Animation = nil – Animation Location Here

local Tool = nil – Tool Location Here

Tool.Equipped:Connect(function()

Anim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(Animation) – This variable will not take local so that it is global and you can use them in other places such as unequipment

Anim:Play() – what you want to happen when you equip the weapon

end)

Tool.Unequipped:Connect(function()

Anim:Stop() – what you want to happen when you unequip your weapon

end)

Provided the local script, gun system is FE gun kit edited

Provided the local script, gun system is FE gun kit edited.