Having multiple frames or duplicating models into one frame?

Hi, I’m a new developer and I’m trying to make a shop where players can buy stuff. I have a frame that shows viewport images of all the objects in the shop (First image) and when the player clicks on one of the images the screen changes to a bigger viewport and with text along side it (second image).

I’m not sure if I should have one frame and delete and add models to the viewport (second image) or have multiple frames with the models of one item in the shop, and change the visibility of the frames.

Code that I’m using when you go from first image to second-

local Gui = game.Players.LocalPlayer.PlayerGui:WaitForChild("Shop")
local MainFrame = Gui.MainFrame
local BaseFrame = MainFrame.BaseFrame
local Scrolling = BaseFrame.ScrollingFrame
local PlasmoButton = Scrolling.PlasmoButton
local InfoScreen = MainFrame.InfoScreen
local Viewport = InfoScreen.ViewportFrame
local Info = InfoScreen.InfoFrame
local Frame = InfoScreen.Frame
local Oilivia = game:GetService("Workspace").Towers.Oilivia
local Plasmo = game:GetService("Workspace")["ShopStuff (Don't delete)"]

local Damage = Info.Damage
local Range = Info.Range
local FireRate = Info.FireRate
local Detection = Info.Detection
local Effects = Info.EffectsNone
local Level = Viewport.Level

--Set stuff when the game starts running
Gui.Enabled = false
MainFrame.Visible = true
Gui.Background.Visible = true
BaseFrame.Visible = true
InfoScreen.Visible = false


--Change Screens based on buttons and add Tower model's
	BaseFrame.Visible = false
	InfoScreen.Visible = true
	for _,v in pairs(Plasmo:GetChildren()) do 
		local clone = v:Clone()
		clone.Parent = game.Workspace
		clone:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(102.82, -254.96, 269.366)
		if v.Name == "PlasmoLevel1" then 
			clone.Parent = Frame["Level 1"]
		elseif v.Name == "PlasmoLevel2" then 
			clone.Parent = Frame["Level 2"]
		elseif v.Name == "PlasmoLevel3" then
			clone.Parent = Frame["Level 3"]
		elseif v.Name == "PlasmoLevel4" then
			clone.Parent = Frame["Level 4"]
	local clone = Plasmo.PlasmoLevel1:Clone()
	clone.Parent = game.Workspace
	clone:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(102.82, -254.96, 269.366)
	clone.Parent = InfoScreen.ViewportFrame
	Damage.Text = "5"
	Range.Text = "5"
	FireRate.Text = "2.2s"
	Level.Text = "Level 1"
	Detection.Text = "No"
	Effects.Text = "None"

I would suggest your second frame (the item details frame) would be dynamic. Having only one with its viewportFrame. And upon player clicks any shop item button, you populate that itemDetailsFrame with the item information and the model into the viewport, (deleting the previous model from vp)

I think its better to not give thousands of frames (if the case) to the client, one per item, if you can use only one which will be updated depending on the item they want to check

Just to clarify, you mean using only one frame and changing the values displayed by the text and adding models when the player clicks on a item right?

Yes, using one frame as your Item Viewer. You make it visible when the player clicks an item in your shop, and you populate all its frames, text, models in viewport, etc, using the data you have from the item.

Thanks for the clarification! I’ll keep this in mind if I’m making something similar in the future.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.