Question, Could you tell me what I did wrong?

So I have a Script that runs an animation, but I want it to have the Run Animation after like normal after the anim plays.

UIS.InputBegan:Connect(function(input,pro)
	local character = player.Character or player.CharacterAdded:Wait()
	local humanoid = character:WaitForChild("Humanoid")
	-- Boost
	if input.KeyCode == Enum.KeyCode.LeftShift or input.KeyCode == Enum.KeyCode.RightShift then
		local ofset = 5
		humanoid.WalkSpeed = 50
		local animation = Instance.new("Animation")
		animation.AnimationId = "rbxassetid://" .. tostring(myAnimId)
		local animTrack = humanoid.Animator:LoadAnimation(animation)
		for _, playingTrack in pairs(humanoid.Animator:GetPlayingAnimationTracks()) do
			playingTrack:Stop(0)
			if not Run then
				ofset = 0
				break
			end
			if animTrack and animTrack:IsA("AnimationTrack") and not animTrack.IsPlaying then
				animTrack:Play()
			end
		end
		wait(ofset)
		animTrack:Stop()
		humanoid.WalkSpeed = 20
        --insert code to walk here
	end
end)


Hello, anyone? All Answers Help.

Could you elaborate further? I cannot understand what you want to achieve based on your post. But from my observation on your code, I recommend loading the animation only once and you should not stop all animations that are playing, instead you can modify an AnimationTrack’s Priority property.

I’m trying to play an anim then continue another anim. (from the animate script in a character)

Could you show or explain what your code is doing to the character in terms of playing the animation?

I just need a code to continue the animation from the Script “animate.”

Well I think you should not stop all the playing animations. Instead you can modify your AnimationTrack’s Priority property to Action so it would overwrite the animations that are already playing and then when the animation stops, the animations that are being handled by the Animate script can naturally resume all of it.

1 Like

Wow, I didn’t even know about animation priorities, thank you for the help

1 Like

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