Hard to explain exactly what’s going on so I’ll just include a reference. (ignore the end)
I’ve tried:
calling LoadAnimation beforehand
creating rig upon tool creation
checking if animation.length is greater than 0 before playing the animation
setting up a promise mechanic to return the animation when it’s length is > 0
Code: (is a bit of a mess right now as I’ve been just sticking random attempts of fixing it in)
function FPSController:RetrieveRigGrip()
local rig = self.rig
local rigGrip = rig.HumanoidRootPart.Handle
return rigGrip
end
function FPSController:CreateRig()
local newRig = viewModel:Clone()
self.rig = newRig
newRig.Parent = self.camera
end
function FPSController:BindTool(tool : Model)
local rigGrip = self:RetrieveRigGrip()
tool.Name = "Weapon"
tool.Parent = self.rig
rigGrip.Part1 = tool.Handle
end
function FPSController:EquipTool(toolName : string)
self:CreateRig()
local weapon = weapons:FindFirstChild(toolName)
if weapon then
local weaponClone = weapon:Clone()
self:BindTool(weaponClone)
local equipAnimation = self.rig.AnimationController.Animator:LoadAnimation(ReplicatedStorage.Animations.UMPEquip)
repeat task.wait() until equipAnimation.Length > 0
print(equipAnimation.Length)
equipAnimation:Play(0)
-- table.insert(self.loopingAnims, idleAnimation)
end
end