How to make a basic custom animation system for custom rigs

DISCLAIMER:

I am not a gaming god scripter like other people, keep that in mind.

Animation Priority’s still matter!

This post is for people who are trying to make their custom Animator script, that can play animations on a custom rig!

Part 1, Making the Script

Firstly, you want to make a local script and put it into StarterCharacterScripts, this is so that we can easily access important parts of the character like the Humanoid.

Next, you need to get the humanoid, animator, and access all of the animations you want to be played on the character!

Here is an example:

local character = script.Parent -- Getting the character so we can easily access the Humanoid to simplify the script.
local humanoid = character:WaitForChild("Humanoid") -- Getting the humanoid so we can access important properties.

local idleAnim = Instance.new("Animation") -- Accessing the animation
idleAnim.AnimationId = "rbxassetid://xxxxxxxxx" -- Getting the Animation Id
local idleAnimTrack = humanoid:WaitForChild("Animator"):LoadAnimation(idleAnim) -- Making a animation track, so the animation can be loaded onto the Character.

local runAnim = Instance.new("Animation")
runAnim.AnimationId = "rbxassetid://xxxxxxxxx"
local runAnimTrack = humanoid:WaitForChild("Animator"):LoadAnimation(runAnim)

Now, to play the animation, we need to start considering some factors…

Onto the next part!

Part 2, Taking things into consideration

Make sure that you take every detail into consideration, the script won’t work if you just have something like

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

local Animation = _____

local AnimationTrack = _________

Humanoid.Running:Connect(function()
   if Humanoid.Running then
     AnimationTrack:Play()
end

if Humanoid.WalkSpeed = 0 then
   IdleAnimation:Play()
end

If you were to use a script like this to animate the player, it wouldn’t work due to the fact that you did not think about states at all.

Because, after the humanoid jumps, you did not check for the walking animation if the player was getting back up, therefore, the player model would keep walking.

Humanoid States, are states that the humanoid are currently going through.

For an example, if a character is walking, the humanoid state will have to check if the humanoid state is running, and it would also have to check if the humanoid just got up, or if their freefalling, same with other states.

To fix the last script, we would have to consider the Humanoids WalkSpeed.

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

local Animation = _____

local AnimationTrack = _________

humanoid.Running:Connect(function(speed)
	if speed > 0 then -- Checks if the Humanoids speed is greater than zero, basically saying that the humanoid is running
		runAnimTrack:Play()
		idleAnimTrack:Stop()
	elseif speed == 0 then -- If the speed is zero, play the Idle animation because the character isn't moving
		runAnimTrack:Stop()
		idleAnimTrack:Play()
	end
end)

HumanoidStates can be used with the state, FreeFalling, so if you want to make a animation of free falling that doesn’t overlap all other animations, you would have to consider if the humanoid is in the state of GettingUp or FreeFalling.

There is a whole documentation on the new Roblox Documentation site, their may be one on the old one, but Im linking this one instead because it feels easy to navigate through.

You can view the page, and check for specific HumanoidStates that can be used to avoid animation overlapping, that is, if you have made a custom character animation script.

-- A rip from my original script.
humanoid.FreeFalling:Connect(function() -- Checks if the Humanoid is in the State of FreeFalling
	if not humanoid.GettingUp then -- checks if the Humanoid isn't getting up after a free fall
		fallAnimTrack:Play()
	elseif humanoid.GettingUp then
		fallAnimTrack:Stop()
		idleAnimTrack:Play() -- Plays idle animation because the character just started standing up after freefalling.
	end
end)









Recap

1. Make sure to consider Humanoid States, if you want to make a working custom Animator.

2. Animation Priorities still matter if you want to avoid animation overlapping!

3. Consider every possibility in ANY code.


Thanks for viewing this post, if you need any help, make sure to ask in the comments.

Other Post…

How to Scale UI on All Devices

Guide To Making a Good Roblox Game - Resources / Community Tutorials - DevForum | Roblox

17 Likes

its best if u use magnitude for your “custom” animator script

It would be best if you would leave how this can exactly be improved instead of just saying magnitude, because Im not really sure on how thats going to help. What your leaving here is pretty broad and doesnt really help me understand why I should use magnitude. Considering that this is old and should probably be updated It would help it that was explained.

Also, I dont really get how its not custom considering the tutorials goal was to make
your own animation system that fits for a custom rig that you’ve created opposed to R6 or R15 or Rthro even.

1 Like

i meant move direction. Using humanoid :disappointed_relieved:

1 Like