Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

With a script, how can you insert something, and place it's parent?

With a script, how do you give it a parent, like a GUI,

Say you inserted a ScreenGui, and you want to put a frame inside of the ScreenGui. Would you do it this way?

local s = instance.new("ScreenGui")
local f = instance.new("Frame",ScreenGui)

Is that a way to do it? Is it like inserting a brick into workspace from script?

2 answers

Indeed, that is the correct way. But you would not be able to see it as you have not set the ScreenGui a parent:

also, ScreenGui's would be put in the PlayerGui's, so here's the correct script

player = game.Player.LocalPlayer
s = Instance.new("ScreenGui", player.PlayerGui) --Puts a ScreenGui in the PlayerGui
f = Instance.new("Frame", player.PlayerGui.ScreenGui) --Puts a Frame, inside the ScreenGui, which is inside the PlayerGui

2 comments

0

For the second parameter of the second Instance.new call, you can just use 's', since that ScreenGui is already defined as that variable.

0

true. either way works

local s = instance.new("ScreenGui",Workspace)
local f = instance.new("Frame",ScreenGui)

That should do it :)

This discussion is preserved as it was. New answers, comments, and votes are closed.