Is there a way to automatically make items go into a viewport frame?

I have been making a inventory system and I was going to make it automatically add items into viewport frames since I don’t want to add every item to it.

So is there a way to code that??? I just cant seem to find it

There is a way to automatically code that. You would have to set the viewport’s camera CFrame according to the size of the object. You just have to translate how you would do it manually, but just into code.

1 Like

This is a modded system used in Bloxy Kart for the Character Preview and Character List System:

	local ViewportFrame = -- Viewport Frame Here.
	local Model = --Put your model here, and clone it with :Clone()
	Model.Parent = ViewportFrame

	local Camera = Instance.new("Camera")
	Camera.Parent = ViewportFrame
	Camera.CFrame = CFrame.new((Model.PrimaryPart.CFrame * CFrame.new(0,0,-8)).Position + Vector3.new(3,0,0), Model.PrimaryPart.Position) -- This is where you would adjust your camera. Be sure to have a PrimaryPart in your model if you are doing a direct copy and paste.
	Camera.FieldOfView = 30
	ViewportFrame.CurrentCamera = Camera

Unfortunately, you have to make a system that works with your Inventory System, and above is just a start for you.

4 Likes