Issue with Viewmodel Gun Scripting

Hey everyone! To start off, I’m fairly new to coding and animation and I’m attempting to expand my skillsets here by trying to code a simple gun system using viewmodel animations. The gun system is meant to be FPS.

My current issue:

The Animations I have setup don’t seem to play when I want them to in the script. The export process from Blender went nicely and saving + playing the animation in ROBLOX went without issue as well… This leads me to believe that something is wrong with the script itself, and I am completely at a loss here.

(NOTE: I am aware that the animations all say play in the code block below, but they dont play regardless of them being “:Stop()” or “:Play()”.)

So far, I’ve tried playing the animation on its own without complexities, I’ve also tried using the recently deprecated way of loading animations (Which is through the humanoid instead of through its animator). This goes without saying, the current way I’m loading the animations is WITH the animator.

Some extra info here, I also made sure to check the rig incase parts were named differently, but everything matches up. “Left Arm” to “Left Arm” etc.

local uis = game:GetService("UserInputService")

local tool = script.Parent
local animationdir = tool.Animations
local handle = tool.Handle

tool.Equipped:Connect(function()

	local player = game:GetService("Players").LocalPlayer
	local character = player.Character
	local humanoid = character:WaitForChild("Humanoid")

	local animator = humanoid:FindFirstChild("Animator")

	local firstdraw = true


	if firstdraw == true then
		local firstdrawanim = animator:LoadAnimation(animationdir.FirstDraw)
		firstdrawanim:Play()
		firstdraw = false
		wait(0.1)
		local idleanim = animator:LoadAnimation(animationdir.Idle)
		idleanim:Play()
	else
		local drawanim = animator:LoadAnimation(animationdir.Draw)
		drawanim:Play()
		wait(0.1)
		local idleanim = animator:LoadAnimation(animationdir.Idle)
		idleanim:Play()
	end
end)

I hope this finds its way to someone knowledgeable in this sort of stuff, and I can get some help. Thanks for reading!

Is the priority of the animation higher than Core? Animation priorities define what level and the priority of how they’re played. Roblox animations are set to Core, and anything else is Idle, Movement, and Action.

If an idle animation is playing over a core animation, only the idle animation will play, movement is higher so it will mimic the same behavior, and same as Action.

Hello, Ben

Thanks for responding, yes I have each animation set as an “Action” currently.

Are you using the same rig models? Like R15 and R6. Because playing an R6 with an R15 animation won’t work.

Hello Ben,

Yes I am currently using the same R6 rig for the animation.