Best way to change core walk/running animations during the game runtime?

Been having a look around the forum, but haven’t fount an answer that makes sense for my use case.
Essentially I have a game where your walk animation may change a lot during playtime. Example being that having a certain ability may make you run differently or wielding certain tools will make you run differently.

Essentially, the walking animation must change frequently during the game for some players and that change also needs to be seen for other clients. What is the best way to go about this> I tried changing the animate values (Animate.walk.WalkAnim.AnimationId) but for some reason it didn’t work for me, although I’ve seen some posts saying it works for others.

I also have a custom walk animation in the game rightnow using the Animate script from roblox in starter character scripts.

2 Likes

It’s actually relatively trivial, in my own research I stumbled across a few threads but none of them had found a solution, all you need to do is locate the desired animation object from within the ‘Animate’ script and change its ID. The following script changes the default run animation to the ninja run animation.

local Game = game
local Players = Game:GetService("Players")

local function OnPlayerAdded(Player)
	local function OnCharacterAdded(Character)
		local Animate = Character:FindFirstChild("Animate") or Character:WaitForChild("Animator")
		local Run = Animate:FindFirstChild("run") or Animate:WaitForChild("run")
		local RunAnimation = Run:FindFirstChildOfClass("Animation") or Run:WaitForChild("RunAnim")
		RunAnimation.AnimationId = "rbxassetid://656118852"
	end
	
	Player.CharacterAdded:Connect(OnCharacterAdded)
end

Players.PlayerAdded:Connect(OnPlayerAdded)
3 Likes