Change humanoids run animation with a click of a button

  1. I’m making a rasengan ability, when you click R, a charge happens and then when you run, it does a special run, different than the normal one when you don’t have the rasengan.

  2. Animation only plays for 2 seconds then stops, i tried looping it, also the anim priority is set to movement.

  3. Looking around devforum and couldn’t find a solution.

if info.Key == Enum.KeyCode.R then
		if sf.SetCooldown({plr = player, ability = "Rasengan", check = true}) then return end
		sf.SetCooldown({plr= player, ability = "Rasengan", dura = 3})
		
		print("Pressed")
		
		local rasengan = repStorage.Effects.Rasengan:Clone()
		
		Engine:FireClient(player, "LoadAnim", {Animation = repStorage.Animations.Charge, human = human})
		
		task.delay(2, function()
			rasengan.CFrame = character["Right Arm"].CFrame
			rasengan.Parent = workspace
			
			local m6d = Instance.new("Motor6D")
			m6d.Part0 = character["Right Arm"]
			m6d.Part1 = rasengan
			m6d.C0 = CFrame.new(0,-2,0)
			m6d.Parent = rasengan
			
			for Index, Value in ipairs(rasengan.Attachment:GetChildren()) do
				task.wait()
				Value:Emit(3)
			end
			
			Engine:FireClient(player, "LoadAnim", {Animation = repStorage.Animations.Run, human = human})
			Engine:FireAllClients("RasenganCharge", {Char = character, rasengan = rasengan})
		end)
	end

animation.looped does not replicate to the client from the server.
a solution would be a loop like this
You could also try changing the animation priority in your script to see if that changes anything.

pcall(function() while Animation do
Animation.Completed:Wait()
Animation.Priority=Enum.AnimationPriority.Action
Animation:Play() end end)

Don’t see how that would work for this? Can you explain it?

Also another tip is you can dynamically change the animations of the default animation script by simply putting the animation in the directory and removing the old one. something like this.

if previousanims==nil then
		previousanims = Character.Animate:FindFirstChild("idle")
			if Character:FindFirstChild(Player.Inventory.Gun.Value)==nil then 
				script.idle.Parent = Character.Animate
			end	
		previousanims.Parent = script
		end
end
	if previousanims~=nil then
	if Humanoid.Health>=35 then
			if Character:FindFirstChild(Player.Inventory.Gun.Value)==nil then 
				Character.Animate:FindFirstChild("idle").Parent =script
				previousanims.Parent = Character.Animate
				previousanims=nil
			end	
				
end