Viewmodel Animation not playing?

I’ve got a viewmodel that plays an animation when equipped, i can print out the track and IsPlaying == true but it just wont show in game?

local handler = {}

function handler:Equip(Viewmodel: Model, Tool: Model)
	local GearMotor = Viewmodel:WaitForChild("Right Arm"):WaitForChild("GearMotor")
	local ToolHandle = Tool:WaitForChild("Handle")
	local ToolData = require(Tool:WaitForChild("Data"))
	local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
	local Shirt = Character:WaitForChild("Shirt"):Clone()
	local Humanoid = Character:WaitForChild("Humanoid")


	local AnimationController = Viewmodel:FindFirstChild("AnimationController")
	if not AnimationController then
		AnimationController = Instance.new("AnimationController")
		AnimationController.Parent = Viewmodel
	end
	local Animator = AnimationController:FindFirstChild("Animator")
	if not Animator then
		Animator = Instance.new("Animator")
		Animator.Parent = AnimationController
	end

	local startFunc = coroutine.create(function() ToolData.start() end)

	local animation = Instance.new("Animation")
	animation.AnimationId = ToolData.SetAnimation

	local BodyColors = Character:WaitForChild("Body Colors"):Clone()

	BodyColors.Parent = Viewmodel
	Shirt.Parent = Viewmodel

	Viewmodel.Parent = Character
	Tool.Parent = Viewmodel

	GearMotor.Part1 = ToolHandle
	GearMotor.C0 = CFrame.new(ToolData.ToolOffsetPos) * CFrame.Angles(math.rad(ToolData.ToolOffsetRot.X), math.rad(ToolData.ToolOffsetRot.Y), math.rad(ToolData.ToolOffsetRot.Z))

	local Track = Animator:LoadAnimation(animation)
	Track:Play()
	coroutine.resume(startFunc)
end



function GetBobbing(addition)
	return math.sin(tick() * addition * 1.3) * 0.5
end

function handler.Update(Viewmodel: Model, dt: number, BobbleSpring: ModuleScript)
	Viewmodel.CameraPart.CFrame = game.Workspace.CurrentCamera.CFrame

	local Bobble = Vector3.new(GetBobbing(10),GetBobbing(5),GetBobbing(5))

	local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()

	BobbleSpring:shove(Bobble / 10 * (Character.HumanoidRootPart.AssemblyLinearVelocity.Magnitude) / 10)

	local UpdatedBobbleSpring = BobbleSpring:update(dt)

	Viewmodel.RootPart.CFrame = Viewmodel.RootPart.CFrame:ToWorldSpace(CFrame.new(UpdatedBobbleSpring.Y, UpdatedBobbleSpring.X / 2, 0))


end

return handler

Do you use a world model inside the viewportframe??
if you dont use one the animations cant play

1 Like

i got it figured out, just had to switch the parent of it, sorry for responding so late.

1 Like

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