Changing Default animations while In-game

Currently in my game when you equip a sword, It’s supposed to change ALL default animations. This works fine but on the server animations start overlapping weirdly and the transitions are incredibly all over the place from said overlapping animations.

I’ve tried making the Animator stop all animations when it detects the ID has changed, but it dosent even work.

Right now, the code detects when you have the sword, when the value’s true, it changes the animations to the sword animations, like a sword idle animation.

However the transitions from that point are really weird in walking. As well as that when you unequip the sword, the server starts mixing in all of the default and sword animations at once creating an abomination.

In other words, GOD save me from this animation hell hole. I’ve been trying to do this sense 2 PM and its now 5 PM. 3 hours wasted just for me to be pulling my hair out over this.

Here’s the actual code for it

if CurrentItemSlot["ItemType"] == "Weapon" and CurrentItemSlot["ItemName"] ~= 
nil then
        
local ObjectV = 
game.ReplicatedStorage.Tools:FindFirstChild(CurrentItemSlot["ItemName"]):Clone()
ObjectV.Parent = script.Parent
SolidObject_InPlayer = ObjectV
script.Parent.DefaultAnimater.idle.Animation1.AnimationId = ObjectV.Idle.AnimationId
script.Parent.DefaultAnimater.idle.Animation2.AnimationId = ObjectV.Idle.AnimationId
script.Parent.DefaultAnimater.walk.WalkAnim.AnimationId = ObjectV.Walking.AnimationId
script.Parent.DefaultAnimater.run.RunAnim.AnimationId = ObjectV.Walking.AnimationId
script.Parent.Humanoid.WalkSpeed = 0
wait(.05)
script.Parent.Humanoid.WalkSpeed = 16

else
if script.Parent.DefaultAnimater.idle.Animation1 ~= "rbxassetid://180435571" then
script.Parent.DefaultAnimater.idle.Animation1.AnimationId = "rbxassetid://180435571"
script.Parent.DefaultAnimater.idle.Animation2.AnimationId = "rbxassetid://180435571"
script.Parent.DefaultAnimater.walk.WalkAnim.AnimationId = "rbxassetid://4761468999"
script.Parent.DefaultAnimater.run.RunAnim.AnimationId = "rbxassetid://4761468999"

script.Parent.Humanoid.WalkSpeed = 0
wait(.05)
script.Parent.Humanoid.WalkSpeed = 16



end
end
3 Likes

the gist of changing default animation of a character is

-- I don't know the exact instance names so this might not work exactly,
-- but should provide the logic
Character:WaitForChild("Animate").idle.Animation.AnimationId = id-- whatever id

Alternatively, you can click play and copy the Animate script out of character, put it in StarterCharacterScripts and edit it how you want (though this will be the same for all players; so this won’t work out if you want to have different animations for different players).

I currently already have the Default Animate script inside the character.

The animations are already set and custom, however changing those animations during live gameplay is whats causing the issues.

Did you try putting an edited Animte script with the animationid of the INSTANCES parented to the script (NOT the script variables) in StarterCharacterScripts?

How would that change anything? It would still be the same animations being loaded.

No, if you have a script called ‘Health’ and/or ‘Animate’ , it loads that instead of the default.

Furthermore, keep in mind my first post here (this will only work out if you want all players to have the same animation, otherwise you’ll have to do it at runtime like I’ve shown).

1 Like

The default animator is deleted once you load in. Only leaving the main animation script.

Why would the animator get deleted? Try reading the links I posted and also searching up how to change default animation.

I d i d. I don’t have any problem what so ever with changing the default animations.

Whenever the animation is once again changed to a different animation and back, it for some reason never stops the previous animations. Causing them to all combine into one animation, breaking it.

There’s no issue changing the default animations to begin with, its changing them multiple times while in-game.

You could just put a script of the animations you want to change it to and delete the current one and replace it with the new one.

Screen Shot 2020-03-14 at 6.29.59 PM

It was worth a shot but the server still plays the animation is was last left off on. And then the transitions are still messed up sense the walking animation is still playing on the server. :confused:

Just an update here, Im currently just writing my OWN animation script. Roblox’s is way too many functions and unneeded stuff for the game Im making. So far everythings fine not a single error. If all goes well I’ll post another update and close this sense it should be solved by then.

(right now mine is only 90 lines of code. While roblox’s is over 543 for me currently. The only difference is mine dosent handle tools and dosent handle loading the swimming animations. Thats over 300 less lines… yikes)

Another update, I just finished some further testing and its working fine now. Apparently Roblox’s Default engine reset the animations during each transition between humanoid states.

Currently I just made my own version of an animation script to work flawlessly with exchanging new animations. Thank you everyone for the feedback.

2 Likes