You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to display a model inside the viewport frame which is part of a shop. -
What is the issue? Include screenshots / videos if possible!
The Viewport frames remains empty after running the game.
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I checked if the camera could see the model and if the model was invisible.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
--Variables
local Gui = game.Players.LocalPlayer.PlayerGui:WaitForChild("Shop")
local MainFrame = Gui:WaitForChild("MainFrame")
local BaseFrame = MainFrame:WaitForChild("BaseFrame")
local Scrolling = BaseFrame:WaitForChild("ScrollingFrame")
local PlasmoButton = Scrolling:WaitForChild("PlasmoButton")
local InfoFrame = MainFrame:WaitForChild("InfoScreen")
local Frame = InfoFrame:WaitForChild("Frame")
local Oilivia = game.Workspace:WaitForChild("Towers"):WaitForChild("Oilivia")
local Plasmo = game.Workspace:WaitForChild("Towers"):WaitForChild("Plasmo")
-----------------------------------------------------------------------------------------------------------------
--Set Camera's
for i,v in pairs(Frame:GetChildren()) do
if v:IsA("ViewportFrame") then
local Cam = Instance.new("Camera")
Cam.CameraType = Enum.CameraType.Scriptable
v.CurrentCamera = Cam
Cam.Parent = v
end
end
local Cam = Instance.new("Camera")
Cam.CameraType = Enum.CameraType.Scriptable
Cam.Parent = InfoFrame:WaitForChild("ViewportFrame")
InfoFrame:WaitForChild("ViewportFrame").CurrentCamera = Cam
-----------------------------------------------------------------------------------------------------------------
--Change Screens based on buttons and add Tower model's
PlasmoButton.MouseButton1Up:Connect(function()
BaseFrame.Visible = false
InfoFrame.Visible = true
for _,v in pairs(Plasmo:GetChildren()) do
local clone = v:Clone()
clone.Parent = game.Workspace
clone:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(0,0,0)
if v.Name == "PlasmoLevel1" then
clone.Parent = Frame:WaitForChild("Level 1")
Frame:WaitForChild("Level 1").CurrentCamera.CFrame = CFrame.new(Vector3.new(0,2,12), clone:WaitForChild("HumanoidRootPart").Position)
elseif v.Name == "PlasmoLevel2" then
clone.Parent = Frame:WaitForChild("Level 2")
Frame:WaitForChild("Level 1").CurrentCamera.CFrame = CFrame.new(Vector3.new(0,2,12), clone:WaitForChild("HumanoidRootPart").Position)
elseif v.Name == "PlasmoLevel3" then
clone.Parent = Frame:WaitForChild("Level 3")
Frame:WaitForChild("Level 1").CurrentCamera.CFrame = CFrame.new(Vector3.new(0,2,12), clone:WaitForChild("HumanoidRootPart").Position)
end
end
local clone = Plasmo.PlasmoLevel1:Clone()
clone.Parent = game.Workspace
clone:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(0,0,0)
InfoFrame:WaitForChild("ViewportFrame").CurrentCamera.CFrame = CFrame.new(Vector3.new(0,2,12), clone:WaitForChild("HumanoidRootPart").Position)
clone.Parent = InfoFrame:WaitForChild("ViewportFrame")
end)
Note: My code is probably really bad as I’m a new developer. Also I wasn’t sure if this went in the GUI channel or the scripting channel as I’m not really sure what the issue is.
Thanks in advance!
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.