Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

Log in to vote
1
Answered by 4 years ago

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
0
It didn't do as i wanted, it stopped the custom animation. ZOOP1015 44 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Roblox has their own tutorial on this.

Use this link: https://developer.roblox.com/en-us/articles/using-animations-in-games

Answer this question