I use multiple weapons in my game and each one has a different idle animation stance. I have been using this script to control the idle animations for about a year now. For some reason this morning this script started causing issues. The animation tries to keep animating when the weapon is activated. Causing two animations to blend together and look strange. It worked fine for the last year but today decided it would change.
Can someone look at this script and help me find a solution to pause the idle animation when the tool is activated? Thanks.
local plr = game.Players.LocalPlayer
local Anim2
script.Parent.Equipped:Connect(function()
local Track2 = Instance.new("Animation")
Track2.AnimationId = "rbxassetid://8986666686" --Idle
Anim2 = plr.Character.Humanoid:LoadAnimation(Track2)
Anim2:Play()
end)
script.Parent.Unequipped:Connect(function()
Anim2:Stop()
end)
It’s the new update to the animation system. Its phase 2 was rolled out recently and everyone’s games have been affected. You can temporarily disable the changes by switching workspace.AnimationWeightedBlendFix to disabled, however once phase 3 rolls out, the property will be hidden and forced to be enabled.
If you have a lot of animations playing at the same time, have fun trying to find a solution. A lot of people like you are having the exact same issue and are complaining on Roblox post, although I highly doubt Roblox will revert the changes anytime soon.
Thanks for the info. What about something like this that stops the first animation for a short time. This script doesnt work but the idea might work if written differently maybe?
local plr = game.Players.LocalPlayer
local Anim2
script.Parent.Equipped:Connect(function()
local Track2 = Instance.new("Animation")
Track2.AnimationId = "rbxassetid://8986666686" --Idle
Anim2 = plr.Character.Humanoid:LoadAnimation(Track2)
Anim2:Play()
if script.Parent.Activated then
Anim2:Stop()
wait(.5)
Anim2:Play()
end
end)
script.Parent.Unequipped:Connect(function()
Anim2:Stop()
end)
Yes, that could work. The problem comes when two (or more) animations play together so stopping the old one would work. I personally adjust my old animations’ weight through :AdjustWeight() once a new one plays.
By the way I may be wrong but I think you should easily be able to fix this by putting Anim2 outside of the equipped event, as well as using the Activated and Deactivated events.
local plr = game.Players.LocalPlayer
local Track2 = Instance.new("Animation")
Track2.AnimationId = "rbxassetid://8986666686"
local Anim2 = plr.Character.Humanoid:LoadAnimation(Track2);
script.Parent.Equipped:Connect(function()
Anim2:Play()
end)
script.Parent.Unequipped:Connect(function()
Anim2:Stop()
end)
Tool.Activated:Connect(function()
Anim2:Stop()
end)
Tool.Deactivated:Connect(function()
if game.Players.LocalPlayer.Character ~= nil and Tool.Parent == game.Players.LocalPlayer.Character then
Anim2:Play()
end
end)
I haven’t tried this directly so I don’t know if it has bugs, but this should be a good example of how you could do it.
I modified it slightly because tool was not defined as a variable. But it wont play the idle animation. It doesn’t like line 4. " 16:07:45.595 Players.Darkwulf7777.Backpack.Tool.Idle:4: attempt to index nil with ‘Humanoid’ - Client - Idle:4
local plr = game.Players.LocalPlayer
local Track2 = Instance.new("Animation")
Track2.AnimationId = "rbxassetid://8986666686"
local Anim2 = plr.Character.Humanoid:LoadAnimation(Track2);
script.Parent.Equipped:Connect(function()
Anim2:Play()
end)
script.Parent.Unequipped:Connect(function()
Anim2:Stop()
end)
script.Parent.Activated:Connect(function()
Anim2:Stop()
end)
script.Parent.Deactivated:Connect(function()
if game.Players.LocalPlayer.Character ~= nil and script.Parent == game.Players.LocalPlayer.Character then
Anim2:Play()
end
end)
Yeah starter pack was the issue. So it works until you use the tool, then it stops the idle and does not restart the idle. To clarify it does not play animation after tool is deactivated.
With the new update, two animations will play together and blend depending on their weight. When you use :Play() on an AnimationTrack without specifying a weight (second argument), it will be set to its default so 1. Now, if two animations with a weight of one (same animation priority) play together, they will blend 50% and 50%.
To fix this, you can use :AdjustWeight on old animations to make the new one not blend with them. I personally set the weight of old animations to 0.01 so i’m sure they don’t blend. I use Animator.AnimationPlayed (which in your case would be Humanoid.AnimationPlayed) and use :GetPlayingAnimationTracks() to find old tracks, then I use :AdjustWeight(0.01) on them.
Thanks for the help. I am a total noob and self taught with LUA. So This will take some time for me to attempt.
In theory the only animation I need to adjust the weight of is the one in this script. If I set it to .01 then other animations should play over the top of it correct?
I did some reading and gave it a shot. This is what I tried and as far as I can tell it doesnt do anything. haha.
local function changeWeight (AnimationTrack,Weight)
local Track2 = Instance.new("Animation")
Track2.AnimationId = "rbxassetid://8421787852"
Track2:AdjustWeight(0.01)
end
local plr = game.Players.LocalPlayer
local Anim2
script.Parent.Equipped:Connect(function()
local Track2 = Instance.new("Animation")
Track2.AnimationId = "rbxassetid://8421787852" --Idle
Anim2 = plr.Character.Humanoid:LoadAnimation(Track2)
Anim2:Play()
end)
script.Parent.Unequipped:Connect(function()
Anim2:Stop()
end)
Oh :AdjustWeight isn’t used on Animations themselves, it’s used on AnimationTracks, aka the animations loaded on the humanoid/animator. In your case, the Animation is “Track2” and the AnimationTrack is “Anim2”, so you should do:
I wrote a full script for you, use it if you can’t do it yourself. Let me know if it works cause it may not even work properly.
local tool = script.Parent;
local plr = game.Players.LocalPlayer;
local listener = nil;
local IdleAnimation = Instance.new("Animation")
IdleAnimation.AnimationId = "rbxassetid://8421787852"
tool.Equipped:Connect(function()
if listener ~= nil then
listener:Disconnect();
end);
local character = plr.Character;
if character and character:FindFirstChild("Humanoid") then
local humanoid = character.Humanoid;
local LoadedIdle = humanoid:LoadAnimation(IdleAnimation);
LoadedIdle:Play();
listener = Tool.Unequipped:Connect(function()
LoadedIdle:Stop();
listener:Disconnect();
listener = nil;
end);
end;
end);
I tried this with a couple corrections. It plays the idle animation but the attack still blends with it.
local tool = script.Parent;
local plr = game.Players.LocalPlayer;
local listener = nil;
local IdleAnimation = Instance.new("Animation")
IdleAnimation.AnimationId = "rbxassetid://8421787852"
tool.Equipped:Connect(function()
if listener ~= nil then
listener:Disconnect();
end;
local character = plr.Character;
if character and character:FindFirstChild("Humanoid") then
local humanoid = character.Humanoid;
local LoadedIdle = humanoid:LoadAnimation(IdleAnimation);
LoadedIdle:Play();
listener = tool.Unequipped:Connect(function()
LoadedIdle:Stop();
listener:Disconnect();
listener = nil;
end);
end;
end);
Does setting track priority fix the blend issue? It says idle animations are lower priority than attack animations. Would setting Anim2’ to idle priority stop the blending of animations?