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

How to make an animation play and not stop when a player is walking?

Asked by
XDvvvDX 186
4 years ago
Edited 4 years ago

Hey. I'm making a gun, and I'm looking for a way for my animation to play when the player is walking too because whenever he's walking the animation stops. Thanks.

2 answers

Log in to vote
0
Answered by 4 years ago

Basically you make an animation firstly using animation editor, next you export it and get the id and then use:

local Players = game:GetService("Players")

local function onCharacterAdded(character)
    local humanoid = character:WaitForChild("Humanoid")

    for _, playingTracks in pairs(humanoid:GetPlayingAnimationTracks()) do
        playingTracks:Stop(0)
    end

    local animateScript = character:WaitForChild("Animate")
    animateScript.run.RunAnim.AnimationId = "rbxassetid://616163682"        -- Run
    animateScript.walk.WalkAnim.AnimationId = "rbxassetid://616168032"      -- Walk
    animateScript.jump.JumpAnim.AnimationId = "rbxassetid://616161997"      -- Jump
    animateScript.idle.Animation1.AnimationId = "rbxassetid://616158929"    -- Idle (Variation 1)
    animateScript.idle.Animation2.AnimationId = "rbxassetid://616160636"    -- Idle (Variation 2)
    animateScript.fall.FallAnim.AnimationId = "rbxassetid://616157476"      -- Fall
    animateScript.swim.Swim.AnimationId = "rbxassetid://616165109"          -- Swim (Active)
    animateScript.swimidle.SwimIdle.AnimationId = "rbxassetid://616166655"  -- Swim (Idle)
    animateScript.climb.ClimbAnim.AnimationId = "rbxassetid://616156119"    -- Climb
end

local function onPlayerAdded(player)
    player.CharacterAppearanceLoaded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(onPlayerAdded)

credit to the dev form: https://developer.roblox.com/en-us/articles/using-animations-in-games

Ad
Log in to vote
0
Answered by 4 years ago

If you want the animation to play when the character stops walking, simply set the priority of the animation to idle and play the animation however you decide and whenever the character isn't moving and doesn't have a higher priority animation using the parts used for that animation it'll play the animation (if that make sense)

Answer this question