Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Needing help with my GUI I am creating to learn more about rbx.lua?

Asked by
IcyEvil 260 Moderation Voter
6 years ago

Before you think this is unrelated to scripting, I am messing around with GUIs, ie... full on scripting the entirety of the GUI, no actual physical part in studio, just a script in StarterGui.

As far as I have gotten is to the 'Frame' for it, but when I test it in-game, and look inside of my PlayerGUI, it shows that the Frame is inside of the ScreenGui, but it isn't visible, with the visible property automatically set to true, I simply can't see it.

Before I give you the script, I have checked the output, there is nothing that comes out of it.

Here is a screenshot to show you, in-case you haven't been able to follow along. http://prntscr.com/fr279h

local x = Instance.new("ScreenGui", game.Players.LocalPlayer.PlayerGui)
x.Name = 'Vaux GUI'

local f = Instance.new("Frame", game.Players.LocalPlayer.PlayerGui['Vaux GUI'])
f.Active = true

1 answer

Log in to vote
1
Answered by
arshad145 392 Moderation Voter
6 years ago
Edited 6 years ago

Unefficient use of parenting an instance.

Source : devforum.ROBLOX

Wrong version :

local x = Instance.new("ScreenGui", game.Players.LocalPlayer.PlayerGui) -- Wrong!
x.Name = 'Vaux GUI'

local f = Instance.new("Frame", game.Players.LocalPlayer.PlayerGui['Vaux GUI']) -- Wrong!
f.Active = true


Corrected version:

local x = Instance.new("ScreenGui") -- Create Instance.
x.Name = 'Vaux GUI' -- Make adjustments to properties.
x.Parent = game.Players.LocalPlayer.PlayerGui -- Parent the instance in the last line possible.

local f = Instance.new("Frame") -- Create frame.
f.Active = true -- Make frame active.
f.Size = UDim2.new(0.25,0 ,0.25,0) --Provide a size for the frame, because the initial size is UDim(0,0,0,0)
f.Parent = x -- Parent the frame to the gui, by just stating the variable "x" which is defined above.

Should work now.

I am still learning RbxLua.

Thank you for reading.

0
Thank you! i've been doing lua for a while now but I just never took the time to learn proper GUI scripting etc... Thank you! IcyEvil 260 — 6y
Ad

Answer this question