Command :AdjustWeight() not working on a Animation track

I’m making a custom walking animation script and am using already playing animation tracks, then adjusting the weight according to the direction.
However, when I use this code WalkLeft:AdjustWeight(10,0)WalkLeft stands for an animation track that is already playing but has a weight of 0.
When I run this code the target weight changes but the current weight of the animation doesn’t.

How do I fix this?

1 Like

Try removing the 2nd argument.
So instead of this: WalkLeft:AdjustWeight(10,0),
Write this: WalkLeft:AdjustWeight(10).

I acknowledge you’re trying to make the fade time 0, meaning the weight changes instantly. However this could be what’s causing the issue

1 Like

Please don’t use ChatGPT to help others on this forum. That “function” doesn’t exist and it’s not called like that.

2 Likes

That doesn’t seem to work. it still only changes the weightTarget, but not the weightCurrent.

Can you change the weight of an animation while it’s playing? If not then how do I change the weight of an animation while it’s playing

@SomeFedoraGuy

It actually does exist:

AnimationTrack:AdjustWeight(weight, fadeTime)

ChatGPT code is the worse though.

Edit:

Whoops, I got confused because the ChatGPT reply was deleted.


@OP

Hmmm your code seems correct. I thought weights should be between 1-0 though, so maybe change your code to WalkLeft:AdjustWeight(1,0)?

The second argument (0) is correct if you want there to be no fade time between the weights.

It’s strange that the target weight doesn’t change the current weight. I would add some code to check if the current weight is being changed over some time. It might be that the current weight changes the next frame when fade time is zero.

Edit:

I’m not sure. Your code looks correct to me. I would try doing small tests to rule out problems. (For example, you could do a test where you just change the weight of an animation outside of a loop. Then if that works do a test where you do the same thing but inside a loop, etc.)

1 Like
if FrontToBackNumber > 0 then
			WalkForward:AdjustWeight(FrontToBackNumber)
			WalkBackward:AdjustWeight(0)
		elseif FrontToBackNumber < 0 then
			WalkBackward:AdjustWeight(FrontToBackNumber)
			WalkForward:AdjustWeight(0)
		else
			WalkForward:AdjustWeight(0)
			WalkBackward:AdjustWeight(0)
		end

		if RightToLeftNumber > 0 then
			WalkRight:AdjustWeight(RightToLeftNumber)
			WalkLeft:AdjustWeight(0)
		elseif RightToLeftNumber < 0 then
			WalkLeft:AdjustWeight(RightToLeftNumber)
			WalkRight:AdjustWeight(0)
		else
			WalkRight:AdjustWeight(0)
			WalkLeft:AdjustWeight(0)
		end

This code is played every heartbeat of the local players screen using, RunService.Heartbeat:Connect()
FrontToBackNumber and RightToLeftNumber are a number between 0 and 1, yet this still doesn’t work. What am I doing wrong?

1 Like

Okay, I solve it, apparently, it was the dumbest problem with Roblox itself.
So if you play an animation with a weight of “0” then you can’t adjust the weight anymore, but if you play it with a default weight value of 0.00001… or anything above 0 then you can adjust the weight just fine.
I really think this needs to be fixed since it seems so useless to have it like this.

5 Likes

Just a side note, ChatGPT mentioned AnimationTrack.SetWeight, which I replied that doesn’t exist.

2 Likes

Ah. That makes sense, that would actually help me for the future.

I think the reason why it does this is that setting it to a weight of 0 essentially does the same thing as :Stop(). I see why this happens but its annoying.

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