Have animations transition

Ok so in a previous post i showed a script that has animations swap between night and day however,
that script would not work so i am gonna show the original version of that script .the only way to show the change is if you move. I want there to be a transition for it but can’t seem to figure out how to make it work

local lighting = game.Lighting
local night = 18
local day = 6

local anim1 = script.Parent.BaseAnimate
while true do
	wait(2)
	if lighting.ClockTime > day and lighting.ClockTime < night then
		anim1.idle.Animation1.AnimationId ="rbxassetid://17639503317"
		anim1.idle.Animation2.AnimationId ="rbxassetid://17639503317"
		anim1.walk.WalkAnim.AnimationId ="rbxassetid://17639505779"
		anim1.run.RunAnim.AnimationId = "rbxassetid://17639509045"
	else
		anim1.idle.Animation1.AnimationId ="rbxassetid://17639512359"
		anim1.idle.Animation2.AnimationId ="rbxassetid://17639512359"
		anim1.walk.WalkAnim.AnimationId ="rbxassetid://17639521313"
		anim1.run.RunAnim.AnimationId = "rbxassetid://17639527968"
	end
end 

I really need this for a game and i need it before august

1 Like

Hey Wil! I guess what you are looking for is how to make the animations change without you moving correct? If that is correct, than what you want to do is stop all previous animations by doing

The wording confused me a little :slight_smile: haha

for _, anim in YourAnimator:GetPlayingAnimationTracks() do  
     anim:Stop()
end

Then you can set all your new anims by doing the same thing you are doing if that works for you, but PLAY your new desired idle animation so that the change saves without you having to move. I would also check to see if your animations are set to the correct AnimationPriority value.
This should fix your “having to move to make it show” issue.

For a transition, I assume you are talking about making a smooth transition between the two animations, and for that its simply just either fading your animation out, or creating a transition animation and then stopping the previous animation, playing the transition and when it stops, play the next animation.

Previous > Transition > New

Hopefully this was a little helpful, sorry I am short on time at the moment and I heard I’m not supposed to hand out code lol and I saw no one else responded.

I’m a little confused on where in the script i should add it and what the “for_” and “YourAnimator” is

add it right before all the code in the first segment of the conditional and before all the code in the else statement like so

local lighting = game.Lighting
local night = 18
local day = 6

local anim1 = script.Parent.BaseAnimate
while true do
	wait(2)
	if lighting.ClockTime > day and lighting.ClockTime < night then
        for _, anim in YourAnimator:GetPlayingAnimationTracks() do  
             anim:Stop()
        end

		anim1.idle.Animation1.AnimationId ="rbxassetid://17639503317"
		anim1.idle.Animation2.AnimationId ="rbxassetid://17639503317"
		anim1.walk.WalkAnim.AnimationId ="rbxassetid://17639505779"
		anim1.run.RunAnim.AnimationId = "rbxassetid://17639509045"
	else
        for _, anim in YourAnimator:GetPlayingAnimationTracks() do  
             anim:Stop()
        end

		anim1.idle.Animation1.AnimationId ="rbxassetid://17639512359"
		anim1.idle.Animation2.AnimationId ="rbxassetid://17639512359"
		anim1.walk.WalkAnim.AnimationId ="rbxassetid://17639521313"
		anim1.run.RunAnim.AnimationId = "rbxassetid://17639527968"
	end
end 

and then YourAnimator is inside the Humanoid found by Humanoid:FindFirstChild(“Animator”) so that would be Humanoid:FindFirstChild("Animator"):GetPlayingAnimationTracks()

Hope this clarifies

so something like this?

local lighting = game.Lighting
local night = 18
local day = 6
local anim1 = script.Parent.BaseAnimate
local YourAnimator = script.Parent.Humanoid:FindFirstChild("Animator")
while true do
	wait(2)
	if lighting.ClockTime > day and lighting.ClockTime < night then
		for _, anim in YourAnimator:GetPlayingAnimationTracks() do  
			anim:Stop()
		end

		anim1.idle.Animation1.AnimationId ="rbxassetid://17639503317"
		anim1.idle.Animation2.AnimationId ="rbxassetid://17639503317"
		anim1.walk.WalkAnim.AnimationId ="rbxassetid://17639505779"
		anim1.run.RunAnim.AnimationId = "rbxassetid://17639509045"
	else
		for _, anim in YourAnimator:GetPlayingAnimationTracks() do  
			anim:Stop()
		end

		anim1.idle.Animation1.AnimationId ="rbxassetid://17639512359"
		anim1.idle.Animation2.AnimationId ="rbxassetid://17639512359"
		anim1.walk.WalkAnim.AnimationId ="rbxassetid://17639521313"
		anim1.run.RunAnim.AnimationId = "rbxassetid://17639527968"
	end
end

the transition does not work for some reason

you would also want to play the idle animation after the loop ends to visibly see change, but that loop is just basically to make sure your animations don’t overlap. Someone may say it’s not necessary and that might have some value but it doesn’t hurt to have it there when it’s correctly defined.

  1. play the idle animation after the loop by using YourAnimator:LoadAnimation(Animation):Play(). don’t use the animationId just use the animation instance like for example, anim1.idle.Animation1 would fit in the parentheses of loadanimation()

  2. if there are console errors for this script send them here so i can see why

reach out again if you are still confused but i might ask to see your project file.