Hey, I’m currently dealing with a pretty annoying bug I can’t seem to prevent.
Whenever I equip my weapon, the idle animation is visible for a frame at the start (as evident here)
This does not occur when I don’t call PlayAnimation on the IdleAnim so it’s directly coorelated to that.
I’ve tried to defer stuff to the next frame etc. but the issue is still persistent.
function Rig:EquipWeapon( gunName ) : nil
local weapon = ReplicatedStorage.Assets.Weapons[gunName]:Clone()
--TODO: Create a method to retrieve all animations corresponding to a weapon
local idleAnimationName = "Idle"..gunName
local equipAnimationName = "Equip"..gunName
local rigGrip = self._rig.PrimaryPart.Handle
weapon.Parent = self._rig
rigGrip.Part1 = weapon.Handle
local animation = self:PlayAnimation(equipAnimationName)
local stoppedConnection
stoppedConnection = animation.Stopped:Connect(function()
self:PlayAnimation(idleAnimationName) -- Removing this causes it not to occur
stoppedConnection:Disconnect()
end)
end