Animation not playing on spawn

I was making an intro for a game. But I discovered a bug in my script that I’ve never seen before. My animation isn’t playing. It just gives me the prints instantly.

  13:10:34.127  begun  -  Client - LocalScript:13
  13:10:34.127  played  -  Client - LocalScript:15
  13:10:34.132  ended  -  Client - LocalScript:19
  13:10:38.438  Disconnect from ::ffff:127.0.0.1|57368  -  Studio

I’ve entered the right ID for the animation. I didn’t know what was going on. So that’s why I posted this topic. Here is my script.

local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character.Humanoid
local Animator = humanoid.Animator

local function firsttimeplayingintro(lplayer)
	local spawnanim = Instance.new("Animation")
	spawnanim.AnimationId = "rbxassetid://110683084091515"
	local spawnanimtrack = Animator:LoadAnimation(spawnanim)
	spawnanimtrack.Priority = Enum.AnimationPriority.Action
	spawnanimtrack.Looped = false
	print("begun")
	spawnanimtrack:Play()
	print("played")
	lplayer.Character:WaitForChild("Humanoid").WalkSpeed = 0
	spawnanimtrack.Stopped:Wait()
	lplayer.Character:WaitForChild("Humanoid").WalkSpeed = 16
	print("ended")
end

firsttimeplayingintro(player)
1 Like

try adding a wait before loading the animation, chances are the animation hasnt loaded, thus it doesnt look like it plays. This usually works in my case at least.

Code that should work:

local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character.Humanoid
local Animator = humanoid.Animator

local function firsttimeplayingintro(lplayer)
	local spawnanim = Instance.new("Animation")
	spawnanim.AnimationId = "rbxassetid://110683084091515"
	local spawnanimtrack = Animator:LoadAnimation(spawnanim)
	spawnanimtrack.Priority = Enum.AnimationPriority.Action
	spawnanimtrack.Looped = false
	print("begun")
	spawnanimtrack:Play()
	print("played")
	lplayer.Character:WaitForChild("Humanoid").WalkSpeed = 0
	spawnanimtrack.Stopped:Wait()
	lplayer.Character:WaitForChild("Humanoid").WalkSpeed = 16
	print("ended")
end
task.wait(1)
firsttimeplayingintro(player)

Ohhh now I get how it works.

character limit

1 Like

did my solution solve it? Or did you do something different? If so what?

1 Like

It’s solved don’t worry

character limit again

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.