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

Why cant I make StarterGui the parent of this?

IM trying to create an instance oa a screengui that has the parent of startergui, but it isnt working. I have tried making the parent the workspace, which worked, but when I move the the instance into startergui, nothing shows up. Nothing shows up in the output either

local scrgui1 = Instance.new("ScreenGui",StarterGui)
scrgui1.Name = "scrgui1"

local txtgui1 = Instance.new("TextBox",scrgui1)
txtgui1.Name = "txtgui1"
txtgui1.Text = "Text"

local txtgui2 = Instance.new("TextBox",scrgui1)
txtgui2.Name = "txtgui2"
txtgui2.Text = "Moretext"
txtgui2.Position = UDim2.new(0,200) -- Move it 200px below txtgui1

1 comment

1

Your problem is line 1: You're trying to call 'StarterGui' as if it were a variable; however, the script is taking it as a 'nil value'. A way you can fix this is creating a variable that which defines the 'StarterGui' service, or just replacing the nil value all together. :)

1 answer

✓ Accepted answer

Make a variable first for StarterGui before calling it!

local StarterGui = game:GetService('StarterGui') -- :GetService() is the best way to access a type of service.
local scrgui1 = Instance.new("ScreenGui",StarterGui) -- You can now access StarterGui with a variable replacing game:GetService('StarterGui')
scrgui1.Name = "scrgui1"

local txtgui1 = Instance.new("TextBox",scrgui1)
txtgui1.Name = "txtgui1"
txtgui1.Text = "Text"

local txtgui2 = Instance.new("TextBox",scrgui1)
txtgui2.Name = "txtgui2"
txtgui2.Text = "Moretext"
txtgui2.Position = UDim2.new(0,200) -- Move it 200px below txtgui1

2 comments

0

You copied me. ;-; Jk Jk :P

0

So why dont you need to make the variable of workspace if you have to with other parts?

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