Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Animation stopped by Roblox idle animations, what to do?

Asked by 4 years ago

local player = game.Players.LocalPlayer repeat wait() until player.Character.Humanoid local humanoid = player.Character.Humanoid local mouse = player:GetMouse()

local anim = Instance.new("Animation") anim.AnimationId = "http://www.roblox.com/asset/?id=(animationid)"

mouse.KeyDown:connect(function(key) if key == "r" then local playAnim = humanoid:LoadAnimation(anim) playAnim:Play() game:GetService("StarterGui"):SetCore("ResetButtonCallback", false) game.StarterPlayer.EnableMouseLockOption = false game.StarterPlayer.AutoJumpEnabled = false game. wait(3.2) game:GetService("StarterGui"):SetCore("ResetButtonCallback", true) game.StarterPlayer.EnableMouseLockOption = true game.StarterPlayer.AutoJumpEnabled = true end end)

It plays the animation, but Roblox, when you are not moving, plays an idle animation, and that idle animation makes the animation stop, and then plays the idle animation.

So everytime Roblox plays an idle animation, the animation stops. How do I fix this?

(And the id=(animationid) is my animation id. )

1 answer

Log in to vote
0
Answered by 4 years ago

Issue

Animation stopped by Roblox idle animations, what to do?

Solution

Before we can get to the solution we should probably discuss why this is not working. The issue is because ROBLOX has something called an Animation Priority system. This means animations with higher priority are played over those with lower priority.

There is an Enum for all animation priorities; Enum.AnimationPriority. Ranking them by lowest to highes (1 is lowest, 4 is highest):

  1. Enum.AnimationPriority.Core
  2. Enum.AnimationPriority.Idle
  3. Enum.AnimationPriority.Movement
  4. Enum.AnimationPriority.Action

Derived from: https://developer.roblox.com/en-us/api-reference/enum/AnimationPriority

Your animation likely has a priority lower or equal to Idle. If you want the animation to not get stopped by Idle animations then you will want to use priorities above Idle such as Movement and Action.

You can set the Priority property of an AnimationTrack to change its priority during run time; you can also change the priority through the Animation Editor Plugin provided by ROBLOX.

In this case it is just easier to change the Priority property of your AnimationTrack. If you don't know which variable is your AnimationTrack then look for the :LoadAnimation method. This method returns an AnimationTrack instance.

local playAnim = humanoid:LoadAnimation(anim)

On this line you have humanoid:LoadAnimation(anim) therefore playAnim is an AnimationTrack.

Therefore you can do something like this:

local playAnim = humanoid:LoadAnimation(anim) 

playAnim.Priority = Enum.AnimationPriority.Action
playAnim:Play()
0
So, all I would have to do is re-upload the animation with a higher priority? :D xDreamingLuma -3 — 4y
0
Alternatively you can just change the Priority in the AnimationTrack. But yes that will also work EpicMetatableMoment 1444 — 4y
0
So with my animation button, what is a way I could make it so the first hit of the "R" button plays the animation, but the second makes it stop? xDreamingLuma -3 — 4y
0
It would be better if you asked a separate question, it will be rather difficult to answerin the the comments. Aside from that you could store a variable and increment the variable and if the variable is a certain value you do a different action. EpicMetatableMoment 1444 — 4y
Ad

Answer this question