Viewport Frame animation not changing

Greetings, everyone.
I have the following script:

repeat wait() until game:IsLoaded()
local runService = game:GetService("RunService")
local debris = game:GetService("Debris")
local animToChange = ""

anim = game.Workspace.Interviewer.Humanoid:LoadAnimation(script.IdleAnim)






anim.Looped = true
anim:Play()
runService.RenderStepped:Connect(function()

	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(id)
	if id == "wave" then
		print('wave')
		anim = stuff.Humanoid:LoadAnimation(script.WaveAnim)
		anim.Looped = true
		anim:Play()
	end
end)

I am trying to make it so the animation of the viewport model changes whenever I call the remote event. The error says that on the client event part, the Humanoid isn’t a valid part of the player model. Any ideas on how to fix that? Thanks!

You might want to call :WaitForChild() on the Humanoid, it might not exist when the script runs. Also, double check that there’s a humanoid in the explorer (in Studio, not during a play test) for the script to refer to in the first place.

Another small unrelated note, but if you’re using Humanoid:LoadAnimation(), it’s good practice to always call :WaitForChild() on the Animator in advance, or else the client’s animations might not replicate to the server. See this announcement for more info.

1 Like