Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can i override "Custom Animation" over default walkingAnim/runningAnim ?

Here's the script that i made for the running animation.

local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local runAnim = Instance.new("Animation")
runAnim.AnimationId = "rbxassetid://5827492961"

local character = player.CharacterAdded:Wait()

local humanoid = character:WaitForChild("Humanoid")
local humAnimator = humanoid:WaitForChild("Animator")
local runAnimConfirm = humAnimator:LoadAnimation(runAnim)

local isKeyPressed = false

UIS.InputBegan:Connect(function(input)
	
	if input.KeyCode == Enum.KeyCode.LeftShift then
		isKeyPressed = true
		
		if isKeyPressed == true then
			
			humanoid.WalkSpeed = 32
			runAnimConfirm:Play()
			
		end
		
		
	end
	
end)


UIS.InputEnded:Connect(function(input)
	
	if input.KeyCode == Enum.KeyCode.LeftShift then
		isKeyPressed = false
		
		if isKeyPressed == false then
			
			humanoid.WalkSpeed = 16
			runAnimConfirm:Stop()
		end
	end
end)

2 answers

You can stop the player's current running animations then run your animations

Example here

for i,AnimationPlaying in pairs(Player.Character.Humanoid:GetPlayingAnimationTracks()) do
	AnimationPlaying:Stop()
end
--Load your animation and play it here

1 comment

0

It didn't do as i wanted, it stopped the custom animation.

This discussion is preserved as it was. New answers, comments, and votes are closed.