I am making a gun system and using animations in a server script to control it. The problem is when I tell the idle animation to stop it does not, it is on the “uneqip section” it plays the unequiptrack but does not stop the idle track here is the code:
--Weapon Handler--
weaponEvent.OnServerEvent:Connect(function(player, eventType, tool)
local humanoid = player.Character.Humanoid
local equipTrack = humanoid:LoadAnimation(tool.weaponClient.Animations.Equip)
local unequipTrack = humanoid:LoadAnimation(tool.weaponClient.Animations.Unequip)
local idleTrack = humanoid:LoadAnimation(tool.weaponClient.Animations.Idle)
local reloadTrack = humanoid:LoadAnimation(tool.weaponClient.Animations.Reload)
local shootTrack = humanoid:LoadAnimation(tool.weaponClient.Animations.Shoot)
if eventType == "Equip" then
equipTrack:Play()
wait(equipTrack.Length)
idleTrack:Play()
elseif eventType == "Unequip" then
idleTrack:Stop()
unequipTrack:Play()
elseif eventType == "Shoot" then
cloneShell(tool)
shootTrack:Play()
wait(gameModule.magTime)
shell2:Destroy()
elseif eventType == "Reload" then
cloneMag(tool)
reloadTrack:Play()
wait(1)
mag1.Transparency = 0
wait(reloadTrack.Length - 1)
weaponEvent:FireClient(player, "Reloaded")
wait(gameModule.magTime - reloadTrack.Length - 1)
mag2:Destroy()
end
end)