Why isn't my animation changing?

I have the following script:

repeat wait() until game:IsLoaded()
local runService = game:GetService("RunService")
local debris = game:GetService("Debris")
local anim = game.Workspace.Interviewer.Humanoid:LoadAnimation(script.IdleAnim)
anim.Looped = true
anim:Play()
runService.RenderStepped:Connect(function()

	local stuff = game.Workspace.Interviewer:Clone()
	for i, v in pairs(stuff:GetChildren()) do
		if v:IsA("Part") or v:IsA("MeshPart") then
			v.Anchored = true
		end
	end
	stuff.Parent = script.Parent
	debris:AddItem(stuff, 0.001)
end)

game.ReplicatedStorage.Events.LoadAnimation.OnClientEvent:Connect(function()
	anim:Stop()
	script.IdleAnim.AnimationId = 'rbxassetid://' .. 4940602656
	anim:Play()
end)


why isn’t my animation changing when i fire the event?

You’re doing this:

script.IdleAnim.AnimationId = 'rbxassetid://' .. 4940602656

and it would be

script.IdleAnim.AnimationId = 'rbxassetid://4940602656'

I don’t think it matters. I tested it and it does not make a difference.

it would also be because you’re not reloading the animation by stopping it you’d need to do

game.ReplicatedStorage.Events.LoadAnimation.OnClientEvent:Connect(function()
anim:Stop()
script.IdleAnim.AnimationId = 'rbxassetid://' .. 4940602656
anim = workspace.Interviewer.Humanoid:LoadAnimation(script.IdleAnim)
anim:Play()
end)

You need to remake the animation. Animations are loaded onto the character and the character plays the animations. You cannot “remove” and animation from a Humanoid only stop it. So you have to make two animations at the start and then start and stop the relevant ones.

Instead do

--At the start of the script
local anim = game.Workspace.Interviewer.Humanoid:LoadAnimation(script.IdleAnim)
script.IdleAdnim.AnimationId = -- Insert the other animation Id now
local anim2 = game.Workspace.Interviewer.Humanoid:LoadAnimation(script.IdleAnim)
anim1:Play()

-- Then in the function
anim1:Stop()
anim2:Play()

All I get is a standing character with no animations:
Here is the script based on your suggestions:

repeat wait() until game:IsLoaded()
local runService = game:GetService("RunService")
local debris = game:GetService("Debris")
local anim = game.Workspace.Interviewer.Humanoid:LoadAnimation(script.IdleAnim)
anim.Looped = true
anim:Play()
local waveanim = game.Workspace.Interviewer.Humanoid:LoadAnimation(script.WaveAnim)

game.ReplicatedStorage.Events.LoadAnimation.OnClientEvent:Connect(function()
	anim:Stop()
	waveanim.Looped = true
	waveanim:Play()
end)

runService.RenderStepped:Connect(function()


	local stuff = game.Workspace.Interviewer:Clone()
	for i, v in pairs(stuff:GetChildren()) do
		if v:IsA("Part") or v:IsA("MeshPart") then
			v.Anchored = true
		end
	end
	stuff.Parent = script.Parent
	debris:AddItem(stuff, 0.001)
end)


Try this it might work

repeat
	wait()
until game:IsLoaded()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Debris = game:GetService("Debris")
local Interviewer = workspace.Interviewer
local IdleAnimation = Interviewer.Humanoid:LoadAnimation(script.IdleAnim)
IdleAnimation.Looped = true
IdleAnimation:Play()

ReplicatedStorage.Events.LoadAnimation.OnClientEvent:Connect(function()
	print("Restarting Animation", IdleAnimation) -- For Debugging.
	IdleAnimation:Stop()
	script.IdleAnim.AnimationId = "rbxassetid://4940602656"
	local IdleAnimation = Interviewer.Humanoid:LoadAnimation(script.IdleAnim)
	IdleAnimation.Looped = true
	IdleAnimation:Play()
end)

RunService.RenderStepped:Connect(function()
	local Stuff = Interviewer:Clone()
	for _, Object in pairs(Stuff:GetChildren()) do
		if Object:IsA("Part") or Object:IsA("MeshPart") then
			Object.Anchored = true
		end
	end
	Stuff.Parent = script.Parent
	Debris:AddItem(Stuff, 0.001)
end)
1 Like

Nope, I still get a plain non animated character when running the script.

are there any errors, does the print function work?

SIDE NOTICE: Humanoid:LoadAnimation() is deprecated, use Animator:LoadAnimation()

1 Like

Are you sure this ID exists? If this was taken from the Asset ID URL, then there is a high possibility when moving to rbxassetid:// the id link won’t match up! This is a weird thing with ROBLOX, so to make sure, take your full animation with rbxassetid://4940602656 and try loading it in on a dummy.

2 Likes

oh god you’re right
https://www.roblox.com/catalog/4940602656/Jumping-Wave

1 Like

Try this

repeat
	wait()
until game:IsLoaded()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Debris = game:GetService("Debris")
local Interviewer = workspace.Interviewer
local IdleAnimation = Interviewer.Humanoid:LoadAnimation(script.IdleAnim)
IdleAnimation.Looped = true
IdleAnimation:Play()

ReplicatedStorage.Events.LoadAnimation.OnClientEvent:Connect(function()
	print("Restarting Animation", IdleAnimation) -- For Debugging.
	IdleAnimation:Stop()
	script.IdleAnim.AnimationId = "rbxassetid://4940564896"
	local IdleAnimation = Interviewer.Humanoid:LoadAnimation(script.IdleAnim)
	IdleAnimation.Looped = true
	IdleAnimation:Play()
end)

RunService.RenderStepped:Connect(function()
	local Stuff = Interviewer:Clone()
	for _, Object in pairs(Stuff:GetChildren()) do
		if Object:IsA("Part") or Object:IsA("MeshPart") then
			Object.Anchored = true
		end
	end
	Stuff.Parent = script.Parent
	Debris:AddItem(Stuff, 0.001)
end)

Just because its deprecated doesn’t mean it doesn’t work, and its a good amount of work more to do the animator:loadanimation()

http://www.roblox.com/asset/?id=4940564896 is the real animation ID, got it using a extension.

1 Like

Simple question, but have you looked into animation priority? Perhaps the priority is not set as action.

thats what I used, check the updated script

1 Like

Oh my god! Thanks so much for the help, I’ve been struggling with this for so long! Credits to @Hylician for his contribution too. Keep up the good work fellas!

I would suggest getting BTRoblox or Roblox+ to get proper ids from emotes and such

1 Like

Yep! They are really cool extensions and have lot more too it than just ID’s!

1 Like