So I am trying to change the idle animation in game in a server script after a event with this code.
Char.Animate.idle.Animation1.AnimationId = "rbxassetid://9740883988"
But it does not change it just uses the default animations.
I tried changing it before hand within the script and that works but changing it within the animation under the value does not work.
The thing this code works for R6 but doesn’t work for R15 which I am trying to do now.
Can anyone help?
2 Likes
Hey there, if I may ask how exactly are you changing it through script? Because changing player animations usually involves going into test mode, then looking inside your player model for the “Animate” LocalScript
You’ll want to copy and paste that same LocalScript into “StarterPlayerScripts” and then change the value for the idle animation inside of it. Does this help?
EDIT:
To add on to this, if you’re trying to edit the animation ID while the game is running instead of prior to it starting, that definitely wouldn’t work because the LocalScript saves the preset values within itself and just relies on that, so you’d have to do something differently if you wanted to change the Idle animation while the game is running. Let me know if this is your issue and we can try to explore a solution
3 Likes
Could you show us more information?
This part of it.
You also need to do this:
idle = {
{ id = "http://www.roblox.com/asset/?id=9740883988", weight = 1 },
{ id = "http://www.roblox.com/asset/?id=9740883988", weight = 1 }
},
I mean in the table.
I try to change it with this code. And I already tried to change it within the animate script and it works but I am trying to change it outside of it while the game is running.
And I am trying to change these values
The thing is this works with R6 no problem.
I know but what I am trying to do is change it later while the game is running.
Then make a custom animation script.
So as I said, changing it while the game running will unfortunately be an issue because the Animate script takes the values that are inside of it and then just saves that info in variables within itself, thus the script would not react to any change in the values
What you’ll wanna do in this case is have a LocalScript disable the Animate script after you change the Idle value and then enable it again. This way it “restarts” the script and has it use the current Idle value instead.
There are probably other less “hacky” ways to accomplis this, but they would definitely be more complex. Let me know if this works for you
I am trying to change the animation like this through a script.
https://gyazo.com/a1387c50f9eefaef9b48cbd42c4a7c70
So it works with R6, but here what happens when I try to change it the same exact way with R15.
https://gyazo.com/6660b5fe048574647de31e194b4ca4d5
…It ends up not working
okay so I don’t have the code on hand but i think you can figure it out
so, when player walkspeed = 0 (this is easily customizable), it will do “YourIdleAnimation:Play()”, then
if player walkspeed = say over 0 then it will stop your idle animation.
Disabling it and reenabling it does not work what I did find was changing then Animation from standard to player choice it works but the player choice animations override the already set animations inside of the preset animate script… so that doesn’t work.
Here’s a sample I made for you, don’t directly copy the code, change it to how you need it exactly,
local function Animation()
Humanoid.Running:Connect(function(speed)
if speed > 0 then
add your animations here for non-idle
else
add the idle animations here
end
end)
end
You can add your animation info above the function (your choice) and then call on it with Animation:Play()/:Stop()
1 Like
The above solution was the closest I can get this to work without it being hacky. I also found another solution; Making another animate script with the animations I want and replacing the new one with the old whenever I want to change the idle animation.
2 Likes
your way does work but if you want it to be more customizable then do my way, that way you can change it if needed.