Hello! im trying to make a transition between walk and idle as shown in this video, but i cant figure how to code it. if anyone knows how please reply thanks.
Hello! im trying to make a transition between walk and idle as shown in this video, but i cant figure how to code it. if anyone knows how please reply thanks.
Play idle and walk at the same time, & smoothly blend their weights based on movement speed
local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local idle = Instance.new("Animation")
idle.AnimationId = "rbxassetid://[your id :P]"
local walk = Instance.new("Animation")
walk.AnimationId = "rbxassetid://[your id :P]"
local idleTrack = animator:LoadAnimation(idle)
local walkTrack = animator:LoadAnimation(walk)
idleTrack.Looped = true
walkTrack.Looped = true
idleTrack:Play()
walkTrack:Play()
humanoid.Running:Connect(function(speed)
local alpha = math.clamp(speed / humanoid.WalkSpeed, 0, 1)
idleTrack:AdjustWeight(1 - alpha)
walkTrack:AdjustWeight(alpha)
end)
It’ll work because both of the animations are playing, & the script blends their weights based on movement speed.
If you’re asking why play 2 animations & have them blend, and how that even works, Roblox mathematically blends the joint rotations, so you never see two animations at the same time, you only see one combined pose, & that’s why it looks like a single smooth animation instead of 2 overlapping ones.
Idle weight = 1, Walking = 0 > you see only Idle
- Idle = 0.7, Walk = 0.3 > mostly Idle, slightly Walking
- Idle = 0, Walk = 1 > you see only Walking
By doing this, you can perfectly blend them.
where would i put this tho?, bcuz i use the roblox animate script
Since you’re using the default Animate script, you don’t want to replace it that controls all the built-in animations. The easiest way is to make a SEPERATE LocalScript in StarterCharacterScripts and put your walk/idle blending code there.
Basically
- Animate.lua stays as-is.
- Your LocalScript loads your Idle and Walk animations using the character’s Animator.
- Then it smoothly blends their weights based on speed.
StarterPlayer
└── StarterCharacterScripts
├── Animate.lua < Roblox default
└── IdleWalkBlend.lua < Your blending script
Don’t edit your old code; leave it as is, just add what I gave you to StarterCharacterScripts ![]()
Thanks! (to bypass the filter)
Your welcome, have a great rest of your day ![]()
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.