Animations inside Viewport GUI not working, even with a WorldModel

I’m trying to make a loot crate oppening animation inside a GUI using a viewport.

This is whats inside the viewport:

And this is whats inside the Animator script:

local animation = script:WaitForChild("Animation")
local humanoid = script.Parent:WaitForChild("Humanoid")
local anim = humanoid:LoadAnimation(animation)

	print("playing crate animation")
	anim.TimePosition = 0

The animation just wont play for some odd reason, the script gets the event and starts the animation, the viewport doesn’t update it i guess.

This is the crate animation:

…And the animation inside the viewport:

(i used tween service to tween the crate going up and down btw)

Heres the Main Controler script:

local TS = game:GetService("TweenService")
local info =,Enum.EasingStyle.Back,Enum.EasingDirection.Out)
local info2 =,Enum.EasingStyle.Back,Enum.EasingDirection.In)

local function tweenModel(model, CF,tweeninfo)
	local CFrameValue ="CFrameValue")
	CFrameValue.Value = model:GetPrimaryPartCFrame()


	local tween = TS:Create(CFrameValue, tweeninfo, {Value = CF})


local function createViewport()
	local viewportFrame ="ViewportFrame")
	viewportFrame.Size =,0,1,0)
	viewportFrame.Position =,0,0,0)
	viewportFrame.BackgroundColor3 =, 0, 0)
	viewportFrame.BorderColor3 =,0,0)
	viewportFrame.BorderSizePixel = 0
	viewportFrame.BackgroundTransparency = 1
	viewportFrame.Parent = script.Parent.CrateGui
	viewportFrame.ZIndex = 50
	viewportFrame.Name = "CrateViewport"

	local box = game.ReplicatedStorage.ViewPorts.Box:clone()
	box.Parent = viewportFrame

	local fakeCam = game.ReplicatedStorage.ViewPorts.Cam:clone()
	fakeCam.Parent = viewportFrame

	local worldModel ="WorldModel")
	worldModel.Parent = viewportFrame
	worldModel.PrimaryPart = box.PrimaryPart

	local viewportCamera ="Camera")
	viewportFrame.CurrentCamera = viewportCamera
	viewportCamera.Parent = viewportFrame
	--viewportCamera.CFrame = box:GetModelCFrame() *,1,5)
	viewportCamera.CFrame = fakeCam.CFrame
	return box, worldModel

	local box, worldModel = createViewport()
	tweenModel(worldModel.PrimaryPart.Parent, worldModel.PrimaryPart.Parent:GetPrimaryPartCFrame(),7,0),info)
	tweenModel(worldModel.PrimaryPart.Parent, worldModel.PrimaryPart.Parent:GetPrimaryPartCFrame(),7,0),info2)

I’ve tried basicly everything i knew and i searched on the dev forum for help, i found that i needed to use WorldModels, but no luck. I tested to see if it was an animation problem but it was working perfectly fine.

try parenting the box to the WorldModel.

also you should probably use Animation Controller when animating object and try playing the animation using local script instead of a script

thanks, but sadly it didn’t help me a bunch, i made the script a localscript, i used an AnimationControler instead of the humanoid, i tried messing arround with the WorldModel, i even took the script out of the model and put inside the GUI where the Main controler script as at and used a RemoteEvent to fire it with the box, parents and stuff but nothing

You’re doing this on Local Script or regular Script?
Animations should (or even have to) be loaded in and played from Local Script.

I tried both but nothing, i even moved the scripts outside the model to see if it worked but no

I would recommend using :WaitForChild() to make animations load in.
Most propably - script tries to load in animation before object existence begin.
Also - try using TweenService
It better option than quick-tweening which is partically deprecated
Try putting this as first line in animation handling script.

local object = viewportFrame:WaitForChild(-- what object/part you're looking for)

still nothing, i’ll try a couple more things and wait a little more to see if more people answer
if nothing works then ima just use tween service and hinges to animate the crate
thanks for the help

That’s what Im saying.
It’s less glitchy and safer to use TweenService.
Also - could You provide me a footage or video of what happening, and explain what do You want to achieve?

I’m trying to put this animations

…inside the viewport crate

but it just doesnt play

1 Like

I have no idea what is going on then.

where you record the videos? is gyazo?

no, i was using the default roblox studio recorded, but i usualy record stuff with OBS Studio

i changed it, now with tween service its working