Viewmodel animation won't play?

I made a viewmodel and am trying to play animations i’ve made for it. The model is rigged correctly and has all the needed components but it won’t play at all.
image



	
local hum = script.Parent:FindFirstChild("Humanoid")

local humanim = hum:LoadAnimation(script.ReceiverGrab)
wait(3)
	humanim:Play()```

Make sure your viewmodel has an Animator and AnimationController, and also load animations onto the Animator.

If that doesnt work, make sure youre attempting to load the animations onto the correct model, and that the script even works in the first place.

1 Like

I believe I’m doing those now and it still doesn’t work

https://create.roblox.com/docs/reference/engine/classes/WorldModel

I do not know what to do with this information

Im sorry, I should have been more verbose.

put a WorldModel instance, as a child of your viewport frame
then put your model to animate as a child of worldmodel

I’m not using viewports I’m just cframing it with the camera, and I’m just trying to get the animation to play on the model separate just in the workspace for now

I am so sorry, totally my bad, I misread the title… ugg.

1 Like

Maybe try this:
Parent the model to a local script in StarterPlayerScripts, and then make the local script reparent the model to the camera, and then set its position every frame.

local RunService = game:GetService("RunService")

local ViewModel = script:WaitForChild("ViewModel")
local ViewModelAnimator = ViewModel:WaitForChild("Humanoid"):WaitForChild("Animator")
local GrabAnim = ViewModelAnimator:LoadAnimation(script:WaitForChild("ReceiverGrab")

local Camera = workspace.CurrentCamera

ViewModel.Parent = Camera 

-- When you want the animation to play
GrabAnim:Play()

RunService.RenderStepped:Connect(function(dt)
ViewModel.PrimaryPart.CFrame = Camera.CFrame
end

Ive done this system on a few of my games and it seems to work completely fine.

1 Like

image
image

I keep getting these problems for some reason with this

I know the problem, i made a mistake in the code i supplied.

This should fix the error.

local GrabAnim = ViewModelAnimator:LoadAnimation(script:WaitForChild("ReceiverGrab"))

now i’m back to where it was, it won’t play but there aren’t any errors