ViewportFrame on surfaceGUI

I am making a banner like this one with the characters displayed on the screen
image
I made a script for the banner in local when you want to summon, it works well, now I have to make the script for the screen like the image shown

I made this script, it clone the characters BUUUT the characters are not shown on the viewport frame

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EventBanner = ReplicatedStorage:WaitForChild("Events"):WaitForChild("BannerRefresh")

local MainFrameViewport = script.Parent.MainFrame.BackgroundFrame.StrokeEffect.SummonFrame.ViewportFramesHolder
local Unit1Frame = MainFrameViewport.Unit1
local Unit2Frame = MainFrameViewport.Unit2
local Unit3Frame = MainFrameViewport.Unit3

local banner = "Normal"

EventBanner.Event:Connect(function()
	local UnitsReplicatedStorage = ReplicatedStorage:WaitForChild("Units")
	local UnitNormalBanner = workspace.SummonSettings.NormalBanner
	local unit1 = UnitsReplicatedStorage:FindFirstChild(UnitNormalBanner.Unit1.Value)
	local unit2 = UnitsReplicatedStorage:FindFirstChild(UnitNormalBanner.Unit2.Value)
	local unit3 = UnitsReplicatedStorage:FindFirstChild(UnitNormalBanner.Unit3.Value)
	
	
	if banner == "Normal" then
		Unit1Frame.WorldModel:ClearAllChildren()

		Unit2Frame.WorldModel:ClearAllChildren()

		Unit3Frame.WorldModel:ClearAllChildren()

		local Unit1Cloned = unit1:Clone()
		Unit1Cloned.Parent = Unit1Frame.WorldModel

		local Unit1Model = Unit1Cloned.Model:FindFirstChild(Unit1Cloned.Name)
		local humanoid1 = Unit1Model:FindFirstChild("Humanoid")
		local animator1 = humanoid1:FindFirstChild("Animator")
		local Animations1 = Unit1Model:FindFirstChild("Animations")

		local Animation1 = animator1:LoadAnimation(Animations1.Idle)

		local Unit2Cloned = unit2:Clone()
		Unit2Cloned.Parent = Unit2Frame.WorldModel

		local Unit2Model = Unit2Cloned.Model:FindFirstChild(Unit2Cloned.Name)
		local humanoid2 = Unit2Model:FindFirstChild("Humanoid")
		local animator2 = humanoid2:FindFirstChild("Animator")
		local Animations2 = Unit2Model:FindFirstChild("Animations")

		local Animation2 = animator2:LoadAnimation(Animations2.Idle)

		local Unit3Cloned = unit3:Clone()
		Unit3Cloned.Parent = Unit3Frame.WorldModel

		local Unit3Model = Unit3Cloned.Model:FindFirstChild(Unit3Cloned.Name)
		local humanoid3 = Unit3Model:FindFirstChild("Humanoid")
		local animator3 = humanoid3:FindFirstChild("Animator")
		local Animations3 = Unit3Model:FindFirstChild("Animations")

		local Animation3 = animator3:LoadAnimation(Animations3.Idle)

		Animation1:Play()
		Animation2:Play()
		Animation3:Play()

		Animation1.Looped = true
		Animation2.Looped = true
		Animation3.Looped = true


	end
end)


image

If u guys can help me I’ll really appreciate it ! :heart:

1 Like

I am talking about this when I said on local
image
The 3 characters are shown but not on the screen. (its the same script for both, screen and the local side ui)

1 Like

Is your ViewportFrame in the StarterGui or Workspace?
This demo below has the Adornee of the SurfaceGui set to the intended part rather than being a child of that part.

(After further tests, this is the only way for it to work)

Let me know if this has solved your issue!

1 Like

I can post a demo if you want, let me know

so you put the surfaceGui in the screenGui ?

Yep! Here’s a demo you can explore
Animated_Viewportframe_quick_demo.rbxl (59.9 KB)

It must be in PlayerGui (or StarterGui, which puts it in PlayerGui) and NOT a part of the Workspace

1 Like

it worked, ty !
image

but do you know how can I center correctly my models in the viewport frame ?

The Camera inside the ViewportFrame is what you use to modify the view, you can also modify the position of the models themselves. That’s pretty much it!

1 Like