Animations Completely freezes on Viewmodel

Hello, And Happy New Years Eve.

Off-Topic Rant

We Made it to 2023, Proud of Yourself?

I hope so, We went through a Virus, Economy, and a “Special Military Operation”, We can only hope that this new year will be better, and safer for all of us.


So When testing my FPS stuff, I noticed that the Animations would Randomly stop playing after a certain point, It continues to do this until i equip another Tool, or it Decides to go back to normal.

It works well however, Everything seems to be working, besides this ONE issue, both on Studio and Game it looks good, But this issue happens both on Studio, and on the Roblox Game Itself.

This was tested on the Game itself btw, and not on Studio

Normally, There would be a Firing animation and a Aiming Animation, But that for some reason isnt happening.
It Isn’t the Tool that’s doing it, but the Viewmodel itself, as it appears to just randomly freeze at random points while on the Character, its perfectly fine. What could be going on?
I have Checked the viewmodel and the Script, But there doesn’t appear to be any issues to cause this.

Viewmodel Controller Script
RunService = game:GetService("RunService")

Plr = game.Players.LocalPlayer -- Player
Chr = script.Parent -- Character

Camera = workspace.CurrentCamera -- Camera
Mouse = game.Players.LocalPlayer:GetMouse() -- Mouse

VM = game.ReplicatedStorage.Viewmodel:Clone() -- Viewmodel
VM.Parent = Camera -- Parents to Camera

SwayAMT = -.4 -- Sway Speed
LastCF = CFrame.new()
SwayCF = CFrame.new()
Bobbing = CFrame.new()
 -- CFrame's
local TO: BasePart = Chr["Torso"]
local RA: BasePart = Chr["Right Arm"]
local LA: BasePart = Chr["Left Arm"]
-- Limb's
local Left: Motor6D = TO["Left Shoulder"]
local Right: Motor6D = TO["Right Shoulder"]
-- Motor6D's
NormalArm = Vector3.new(1,2,1) -- Normal Arm Size
Negate = .7 --  Number for Arm Size
ArmNegation = Vector3.new(Negate,2,Negate) -- New Arm Size
-- Arm Stuff
Main = { -- Probably useless
	
	[1] = script.Parent;
	[2] = script.Parent:FindFirstChildOfClass("Humanoid");
	
	
	
}


Limbs = {	 -- also Probably useless
	[1] = Chr["Head"];
	[2] = Chr["Torso"];
	[3] = Chr["Left Arm"];
	[4] = Chr["Right Arm"];
	[5] = Chr["Left Leg"];
	[6] = Chr["Right Leg"]	
}

Atts = {} -- Actually Useless


RunService.RenderStepped:Connect(function()
	--[[ Sway and Bobble Stuff
	local Rot = Camera.CFrame:ToObjectSpace(LastCF) 
	local X,Y,Z = Rot:ToOrientation()
	
	local Rota = CFrame.Angles(math.sin(X) * SwayAMT,math.sin(Y) * SwayAMT,math.sin(Z) * SwayAMT)
	
	
	SwayCF = SwayCF:Lerp(Rota, .1)
	LastCF = Camera.CFrame
	
	Bobbing = CFrame.new(Main[2].CameraOffset.X/3, Main[2].CameraOffset.Y/3, Main[2].CameraOffset.Z/3)
	]]
	RA.LocalTransparencyModifier = 0
	LA.LocalTransparencyModifier = 0
	VM:SetPrimaryPartCFrame(Camera.CFrame * CFrame.new(0,-1.5,0) * SwayCF * Bobbing) -- Follows Camera
	local dist = (Camera.CFrame.Position - Limbs[1].Position).Magnitude -- Camera Zoom Distance
	if dist < 1 then -- Moves Arms Part0 to Viewmodel if Zoomed in
		LA.CastShadow = false
		RA.CastShadow = false
		Right.Part0 = VM.Torso
		Left.Part0 = VM.Torso
		RA.Size = ArmNegation -- New Arm Size
		LA.Size = ArmNegation
	else -- Restores Arms to Character if Zoomed out
		LA.CastShadow = true
		RA.CastShadow = true
		Right.Part0 = Chr.Torso
		Left.Part0 = Chr.Torso
		RA.Size = NormalArm -- Normal Arm Size
		LA.Size = NormalArm
	end
	
	for _,i in pairs(VM:GetChildren()) do
		Mouse.TargetFilter = i -- Filters Viewmodel
	end
	
-- Below here is the Camera Bobbing Effect, Not Important here tho
	
end)

What could be the issue?

I don’t see what’s the problem on your animation. It doesn’t look like it’s randomly stopping. What exactly is the problem here? The empty barrels? The burst effect?

1 Like

The Animations, There is supposed to be a firing and aiming animation, they working normally when in third person, but not in first person.

I cant show footage as it is difficult to replicate this issue

1 Like

Maybe use a WorldModel?

1 Like

I’m not sure how a WorldModel will help here.

From the Docs:

More specifically, you can make a WorldModel a child of a ViewportFrame, and then parent geometry to the WorldModel. This will then allow you to use raycasts in the ViewportFrame through the WorldModel. Furthermore you can put Humanoid characters in the WorldModel and their joints will be set-up correctly, and you can animate them.

Haven’t experimented with them, but you might have luck using them.

Anyway, i got on Studio, this is what it normally looks like:


It has working Animations, but for some reason, they just stop working.

But I dont understand how this will help me, @Y_VRN plus after testing them, it completely broke the viewmodel

Does the output show any errors related to your code?

My bad about this one. I may have had a 40-minute brain fart because I thought you were using a ViewportFrame when you mentioned a view model.

1 Like

No errors

Its fine, lol

I’m not sure if it’s the view model, since there’s no code related to animation in the script you provided. Are there other scripts that animate the view model?

No, The Model gets Animated when the Arms get Attached to it, So when you zoom in, The Arms to go to the Viewmodel, but when you zoom out, they go back into the Character itself

But the Characters Animations go along with the viewmodel since the Arms are still techically attached to it

Its weird because it only stops working on the viewmodel, and not the character

Still wondering about this. :frowning:

As someone who has made plenty of viewmodels, first check if the animation are owned by the main owner of the game/group. Then make sure that shoot and reload are set as action. Keep what you have for aim and make idle an idle.

That’s not the Issue,

The Issue is that the Animations completely stop working on the viewmodel, but with the character it is as if it were normal, I created the Animations btw, and yes, their Priorities are high than the base Animations

There are a few potential causes for animations breaking on a viewmodel in Roblox, and different approaches you can take to try to fix the issue. Here are some steps you can try

  1. Check the animation file itself: Make sure that the animation file is properly formatted and that there are no errors or issues with the file itself. You can do this by opening the animation in Roblox Studio and looking for any red highlighted lines or other error messages.
  2. Check the animation ID: Make sure that the correct animation ID is being used when trying to play the animation. You can check the animation ID by opening the animation file in Roblox Studio and looking at the properties panel on the right side of the screen.
  3. Check the animation folder: Make sure that the animation is located in the correct folder and that the path to the animation file is correct.
  4. Check the animation code: Make sure that the code being used to play the animation is correct and that there are no typos or other errors. Here is an example of code that could be used to play an animation on a viewmodel in Roblox:
local character = game.Players.LocalPlayer.Character
local viewmodel = character:WaitForChild("Gun")
local anim = viewmodel:LoadAnimation(animationFile)
anim:Play()
  1. Check for any other issues: Make sure that there are no other issues with the character or viewmodel that could be causing the animation to break. This could include issues with the character’s rigging or with the animation itself.

If you’ve tried all of these steps and the animation is still not working, it’s possible that there is an issue with the Roblox game itself. In this case, you may want to try restarting the game or checking for any updates that may be available.

Once again, I have no issues with the Animations, Its just the Animations stop working on the Viewmodel, while on the Character its normal

The Motor6D’s Connecting the Arms attach to the Viewmodel, and since they are still connected to the Player’s Character, It Still play’s the animations from the Character

The Viewmodel (or the Arms Connected to the viewmodel) is Playing the Animations from the Character

It works as intended until this randomly happens during gameplay

Certainly! It sounds like you are experiencing an issue with animations not working correctly on the viewmodel in Roblox. Here are a few things you can try to fix this issue:

  1. Make sure that the animation you are trying to play is compatible with the viewmodel. Some animations may not work correctly on the viewmodel, so you may need to use a different animation.

  2. Check to see if the animation has been properly imported into the game. Make sure that the animation file is in the correct format (e.g. .rbxm or .rbxl) and that it has been correctly imported into the game using the Roblox Studio’s Import function.

  3. Check the animation’s properties in the Roblox Studio. Make sure that the animation’s “Use Model Swap” property is set to “True” and that the “Use ViewModel” property is set to “False”.

  4. Make sure that the animation is being played on the correct object. The viewmodel is a different object than the character, so you will need to make sure that you are playing the animation on the correct object.

  5. Check for any errors in the game’s output window. If there are any errors related to the animation, they will be listed in the output window. This can help you identify any issues with the animation and how to fix them.

I hope these suggestions help!

I dont think you are understanding what Im saying,

Im saying that The Arms on the viewmodel are still connected to the Character, therefore can still Play Animations from the Character, It works how I want to, until this randomly happens during gameplay

What my code does to does is connect the Part0 of the Motor6D to the Viewmodel, When this happens it will act as normal and recieve the animations from the Character due to still being Connected from Part1

Only the Arms are Animated for the Weapon

Try to reference it again, but only one of the arms.

And do an else, and then put your error message

There are No Errors