#Need help playing animations

24 messages · Page 1 of 1 (latest)

magic grotto
#

What exactly do you mean by that?

#

Playing the animation ID?

neon yarrow
#

I think so

#

I’m following a tutorial and the person doing the tutorial didn’t have any problems with it

royal sedge
neon yarrow
magic grotto
#

You want to play it on keybind?

neon yarrow
#

No automatically

magic grotto
#

The whole time?

neon yarrow
#

Until it reaches the end and respawns

magic grotto
#

Oh so like an emote

neon yarrow
#

It’s for an enemy In a tower defense game

magic grotto
#

so walking anim?

neon yarrow
#

Yeah

magic grotto
#

wait I think i made something like that let me send you the script

neon yarrow
#

Thx

magic grotto
#

local bot = script.Parent
local humanoid = bot:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

local walkingAnim = Instance.new("Animation")
walkingAnim.AnimationId = "rbxassetid://YOUR_ANIMATION_ID"

local walkAnimationTrack = nil

local function playWalkAnimation()
if not walkAnimationTrack then
walkAnimationTrack = animator:LoadAnimation(walkingAnim)
end
if not walkAnimationTrack.IsPlaying then
walkAnimationTrack:Play()
end
end

local function stopWalkAnimation()
if walkAnimationTrack and walkAnimationTrack.IsPlaying then
walkAnimationTrack:Stop()
end
end

humanoid.MoveDirectionChanged:Connect(function(moveDir)
if moveDir.Magnitude > 0 then
playWalkAnimation()
else
stopWalkAnimation()
end
end)

humanoid.Died:Connect(function()
if walkAnimationTrack then
walkAnimationTrack:Stop()
end
end)

#

I think you need to make a few adjustments

neon yarrow
#

Thx

terse hingeBOT
#

studio** You are now Level 1! **studio

neon yarrow
#

And I put it in all of my enemies

#

Right

magic grotto
#

What do you mean?

neon yarrow
#

The mob is the parent