How can I change a players core animation during RunTime

Hey, I’ve been trying to change the running animation during the runtime so that all other clients can see. Currently I have this script below, my print runs but the animation does not change, why is that?

local SprintAnimation = "rbxassetid://123986004541457"
local RunAnimation = "rbxassetid://127020263541264"

local AnimationHandler = {}

function AnimationHandler.Sprint(player : Player, sprint)
	local character = player.Character 
	if not character then 
		return
	end
	
	
	local animateScript = character:WaitForChild("Animate")
	
	--// Checks to see if they already have that animation playing
	if (sprint and animateScript.run.RunAnim.AnimationId == SprintAnimation) or (not sprint and  animateScript.run.RunAnim.AnimationId == RunAnimation) then 
		return
	end
	
	local animator = character:WaitForChild("Humanoid").Animator

	--// Stop the current animation tracks 
	for _, playingTrack in animator:GetPlayingAnimationTracks() do
		playingTrack:Stop(0)
	end
	
	print("here")
	animateScript.run.RunAnim.AnimationId = sprint and SprintAnimation or RunAnimation
end

return AnimationHandler

I could override by playing my own animation over the top of the movement with a higher priority but I feel like that would be way less efficient then if I can change the core movement animation during run time.
I’m also curious if there is a way I can achieve this on the client?

This is just a Idea:

You can set animation priority to Action4 which is the highest priority and it will run first.

Like this:

local Animation = Instance.new("Animation")

local Humanoid = Instance.new("Humanoid")

local AnimTrack = Humanoid:LoadAnimation(Animation)

AnimTrack.Priority = Enum.AnimationPriority.Action4

I could do that, but it would be inefficient since the core animation is technically still be played by roblox. I’m wondering if there is a way that I can do this with the Roblox Animate script without getting a custom one.

1 Like