Animating Handle doesn't seem to work

Creating an animation handler was a somewhat difficult task for my game, I don’t blame you for being confused about animation weights/priority. Here’s a code snippet from my game, this is in my AnimationHandler module, in which animations are loaded, and given their respective priority.

local findRoot = AnimationModule.AnimationCache[animationType] -- This is an over-arching animation catagory, such as Melee and Movement.
local animationData = findRoot[animationName] -- We pre-cache our animations, this is where AnimationIds, Priority, and Weights are stored.

Example Data: animationData = {
	[1] = 1001; -- AnimationId
	[2] = "Action"; -- Priority
	[3] = 1; -- Weight
}

local loadAnimation = animator:LoadAnimation(animationData[1])
loadAnimation.Priority = Enum.AnimationPriority[animationData[2]]
loadAnimation.Weight = animationData[3]

At this point, you may want to include the code you use to add the weapon to your character as well as your animation handler. My theory is your in-game Motor6D handle does not match the same schema as the one you are animating on. Be sure that the Motor6D you create has the same Parent, Part0 and Part1 property as your animation rig.

1 Like

I see, I didnt think to put any of that in my module. I’ll share that quick:

local AnimationHelper = {}

AnimationHelper.playRequestedAnimation = function(plr, animation, name, prio)
	local newAnim = Instance.new("Animation")
	newAnim.AnimationId = animation
	local playerAnimator = plr:WaitForChild("Humanoid"):WaitForChild("Animator")
	local requestedAnim = playerAnimator:LoadAnimation(newAnim)
	newAnim:Destroy()
	if name == "Idle" then
		requestedAnim.Looped = true
	end
	requestedAnim:Play(0.1, prio, 1)
end

AnimationHelper.StopCurrentAnimations = function(plr)
	local playerAnimator = plr:WaitForChild("Humanoid"):WaitForChild("Animator")
	local playingTracks = playerAnimator:GetPlayingAnimationTracks()
	for i, v in pairs(playingTracks) do
		if v.IsPlaying then
			v:Stop()
		end
	end
end

return AnimationHelper

Above is my AnimationHelper module, the theory was that i could use it for both players and NPCs so i could save time, but im thinking this might genuinely be the source of my problems.

local function onEquip()
	local equipstring = "Equip"
	local myPlayer = script.Parent.Parent
	AnimationHelper.playRequestedAnimation(myPlayer, animations.Equip.Animation.AnimationId, "Equip", 1)
	manageFakeWeaponProp(equipstring)
	CreateSheath()
	ReplicatedStorage.Events.ToggleWeaponCustEvent:FireClient(Players:GetPlayerFromCharacter(myPlayer), true)
	wait(animations.Idle.Duration.Value)
	AnimationHelper.playRequestedAnimation(myPlayer, animations.Idle.Animation.AnimationId, "Idle", 2)
end

This above code is a snippet from the tool itself, using the module. Also, made sure all the motor6Ds are in the tool, how do i get the arm parts into the motors? do i just need to hard-code that on equip?

Alright, so I think I found my issue.
So after, re-looking at the rig, I did some digging into how Roblox makes a rig when you equip a tool.
Turns out, using the default Handle system makes a new weld in the players hand when you equip a tool.

image

I had to disable this in a script in order to make my Motor6Ds in my tools be recognized as part of the rig!

image

image

Thank you all for your time! All of the help with the rig pushed me in the right direction.

1 Like

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