Viewport wont play animation

script.Parent.Parent.ViewportFrame.MouseEnter:Connect(function()
	local humanoid = script.Parent.dummy:WaitForChild("Humanoid")
	local animator = humanoid:FindFirstChildOfClass("Animator")
	local anim = Instance.new("Animation")
	anim.AnimationId = "rbxassetid://14224225681"
	local track = animator:LoadAnimation(anim)
	track.Looped = true
	track:Play()
end)

Screenshot 2023-07-28 173949
it just dosent work on the viewport dummy

Try placing your model Inside a WorldModel

1 Like

I placed the dummy in a world model, didnt work

It should look like this your structure:
→ ViewportFrame
| → WorldModel
| | → Dummy

Is it like that? Is the script inside the Dummy? If yes, where inside it?

  • Viewport
    → Worldmodel
    | → Dummy
    → Localscript

Try this script, make sure WorldModel is named WorldModel

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://14224225681"

script.Parent.Parent.ViewportFrame.MouseEnter:Connect(function()
	local humanoid = script.Parent.WorldModel.dummy:WaitForChild("Humanoid")
	local animator = humanoid:FindFirstChildOfClass("Animator")

	local track = animator:LoadAnimation(anim)
	track.Looped = true
	track:Play()
end)

It is named worldmodel, I tried this version of the script and it just doesn’t work

Can you send me the console output? Also just to be sure, LocalScript is parent of ViewportFrame?

none that is related to the directory or the script

Screenshot 2023-07-28 175302

Put it outside of WorldModel.

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://14224225681"

script.Parent.MouseEnter:Connect(function()
	local humanoid = script.Parent.WorldModel.dummy:WaitForChild("Humanoid")
	local animator = humanoid:FindFirstChildOfClass("Animator")

	local track = animator:LoadAnimation(anim)
	track.Looped = true
	track:Play()
end)

What do I put outside the worldmodel

You put the LocalScript outside the WorldModel, parent it to the ViewportFrame.

its parented to the viewport frame

Have you already changed the script to this one?

I have infact changed to that script

Are you sure there are 0 errors on the output? If there’s any take a screenshot and paste here.

ill try this on a baseplate and see if there would be a output

Simply, your humanoid does not have an “Animator” inside of it.

local animator = humanoid:FindFirstChildOfClass("Animator")

Is returning nil.

1 Like