ViewModel Animations Not Working

The animations don’t play like they could,
Though the variables are not misunderstood.

The code, inside a module, you see,
Parented to a local script, is where it would be.

local function UpdateInit(TemplateStorage,MainGui,Screen,Button,Mobile,Cursor)
	local Type=Get(LocalPlayer,"ViewModel")or"Hand"
	local LastModel,ViewModel=CurrentModel,ViewModelAssets:FindFirstChild(Type)
	CurrentAnimate=ViewModelAnimations:FindFirstChild(Type)

	CurrentModel=ViewModel and ViewModel:Clone()
	if CurrentModel then
		if LastModel then LastModel:Destroy()end
		CurrentHumanoid=CurrentModel:FindFirstChildOfClass("Humanoid")
		CurrentAnimator=CurrentHumanoid and CurrentHumanoid:FindFirstChildOfClass("Animator")
		CurrentModel:ScaleTo(0.2) -- // I dont know why people dont do this, but it changes nothing and prevents clipping due to the model being smaller.
		if CurrentAnimate and CurrentAnimator then
			for Index,Animation in pairs(CurrentAnimate:GetChildren())do
				if Animation:IsA("Animation")then
					AnimationList[Animation.Name]=CurrentAnimator:LoadAnimation(Animation)
				end
			end
		end
	end
end
local function UpdateAttribute(Attribute)
	if CurrentModel and CurrentHumanoid and CurrentAnimator and CurrentAnimate then
		if Attribute=="Sprinting"then
			if Get(LocalPlayer,"Sprinting")then -- // Placeholder for playing animations.
				AnimationList.Idle:Stop()
				AnimationList.Walk:Stop()
				AnimationList.Run:Play()
			else
				AnimationList.Idle:Stop()
				AnimationList.Walk:Play()
				AnimationList.Run:Stop()
			end
		end
	end
end
local function UpdateChanged(Bool:boolean)
	if CurrentModel and CurrentHumanoid and CurrentAnimator and CurrentAnimate then
		CurrentModel.Parent=Bool and GameService.Workspace.Camera or GameService.Lighting
	end
end
local function UpdateModel()
	if CurrentModel and CurrentHumanoid and CurrentAnimator and CurrentAnimate then
		FirstPerson.Value=IsFirstPerson()
		if FirstPerson.Value then
			CurrentModel:PivotTo(CurrentCamera.CFrame*CFrame.new(0,0,-2))
		end
	end
end

I will show you, with this image attached,
Do not forget, and do not snatch.

1 Like

What do you mean by " The animations don’t play like they could ,
Though the variables are not misunderstood ."

Do you mean that all the variables are correct and the animation should play but it doesn’t?

I would suggest handling animations in a local script, not a module script. And try using spaces in between you code, it is very hard to read the way you write your code.

I’m more of an oddball with how I format my code, but for me, it’s just more easy for me to read.
And “all the variables are correct and the animation should play but it doesn’t” is true, when I print in every way possible, it doesn’t come up with any nil’s, yet the ViewModel is static when I try to play an animation.

I will try handling the animations within a local script, but I usually try to create this kind of stuff like this:
Screenshot 2025-08-09 124212

also I was kind of messing around up there with the rhyming don’t mind that got bored

Try handling it in a local script and see if it works, most of the times I’ve tried handling stuff like animations and gui in module scripts in ends up like poop.

Would it be possible to have the module handle the positions and all the other nonsense, and just have the module return the ViewModel information like this:

function Client_ViewModel.Get():(Model?,Humanoid?,Animator?,Folder?)
	return CurrentModel,CurrentHumanoid,CurrentAnimator,CurrentAnimate
end

, and then have the localscript load and play the animations through it.
or would It just all have to be handled within the localscript to verify.

Yes that would probably work, whats important is that you the playing of the animation in a local script like:

– Local script
local animTrack = Humanoid:LoadAnimation()
animTrack:Play()

1 Like

I wasted like hours doing a whole bunch of horsing around and experimenting, just for it to be what it usually is, a singular line was wrong.

look at this line:
CurrentModel=ViewModel and ViewModel:Clone()
This is was incorrect line. use 100% brain power I guess what was wrong here, actually, try and guess. because I got it by sheer luck.

CurrentModel=ViewModel and ViewModel:Clone()
was supposed to be:
CurrentModel=ViewModel
it was this, it was literally this. the “Clone()” Function.
for some reason just messes it up entirely, like the animations just stop working for no reason at all I couldn’t tell you why.

it really stinks, cause I spent a really long time trying to fix this in other ways, I tried out the suggestion, I tried my idea of doing both, ect. but atleast I ended up getting it working anyways, so there’s a bright side

So I guess there’s a lesson to learn here, i forgot the lesson

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