How would I preload animations to stop this from happening>

This is the main function

local function updateLoadout(class)
	if class then  -- Ensure class is not nil
		local classPrimary = classModule[class.Value].Primary
		local classSecondary = classModule[class.Value].Secondary

		loadout.Primary = classPrimary.Viewmodel
		loadout.Secondary = classSecondary.Viewmodel

		if CurrentSlot == 1 then
			camera:ClearAllChildren()
			task.wait()

			currentViewmodel = loadout.Primary:Clone()
			currentViewmodel.Parent = camera
			
			local animations = {
				["Idle"] = currentViewmodel.AnimationController.Animator:LoadAnimation(currentViewmodel.Animations.Idle),
				["Equip"] = currentViewmodel.AnimationController.Animator:LoadAnimation(currentViewmodel.Animations.Equip)
			}
			animations.Equip:Play()
			animations.Idle:Play()

			updateViewmodel(currentViewmodel)

		elseif CurrentSlot == 2 then
			camera:ClearAllChildren()
			task.wait()

			currentViewmodel = loadout.Secondary:Clone()
			currentViewmodel.Parent = camera

			local animations = {
				["Idle"] = currentViewmodel.AnimationController.Animator:LoadAnimation(currentViewmodel.Animations.Idle),
				["Equip"] = currentViewmodel.AnimationController.Animator:LoadAnimation(currentViewmodel.Animations.Equip)
			}
			animations.Equip:Play()
			animations.Idle:Play()

			updateViewmodel(currentViewmodel)
		end
	end
end
1 Like

Not a fan of changing out the viewmodel for a new one each time you change your weapon but oh well. You could simply try offseting the viewmodel behind/under the camera until the animation plays

1 Like

I undertsand but I find it more customizable this way idk.

I solved it by creating a function that makes the viewmodel invisible for 0.1 seconds untill animations load and it’s seamless now.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.