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-
--Variables
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)"]
--Labels
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
PlasmoButton.MouseButton1Up:Connect(function()
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"]
end
end
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"
end)