01 | game:GetService( "UserInputService" ).InputBegan:connect( function (inputobject,gameProcessedEvent) |
02 | --case |
03 | if inputobject.KeyCode = = Enum.KeyCode.Q then |
04 | local file = Instance.new( "ScreenGui" ) |
05 | file.Parent = game.StarterGui |
06 | local paper = Instance.new( "Frame" ) |
07 | paper.Size = UDim 2. new( 0 , 100 , 0 , 100 ) |
08 | paper.Visible = true |
09 | paper.Parent = file |
10 | end |
11 | end ) |
it did create a screen gui and a frame but the frame is invisible. how to make the frame visible?
you are creating the gui in startergui, because you are creating the gui on a key press, i assume this is DURING game, the startergui is basically just a storage service that clones all of its children into a player when he/she joins, move it to the PLAYERGUI instead, im also assuming you are using a localscript or else userinputservice wont work
01 | game:GetService( "UserInputService" ).InputBegan:connect( function (inputobject,gameProcessedEvent) |
02 | --case |
03 | if inputobject.KeyCode = = Enum.KeyCode.Q then |
04 | local file = Instance.new( "ScreenGui" ) |
05 | file.Parent = game.Players.LocalPlayer.PlayerGui |
06 | local paper = Instance.new( "Frame" ) |
07 | paper.Size = UDim 2. new( 0 , 100 , 0 , 100 ) |
08 | paper.Visible = true |
09 | paper.Parent = file |
10 | end |
11 | end ) |
To make the frame visible, it's as simple as this:
1 | local paper = Instance.new( "Frame" ) |
2 | paper.Visible = true |
3 | file.BackgroundTransparency = 0 -- Just to make sure that it's really visible. |
Oh, and I also suggest you make the ScreenGui's Enabled property to true by doing something like this:
1 | local file = Instance.new( "ScreenGui" ) |
2 | file.Enabled = true |
Because the frame's visibility won't matter if the ScreenGui was Disabled. Also take note that if this doesn't work, it may be because you're using the StarterGui instead of the PlayerGui
Use PlayerGui instead of StarterGui. Example:
01 | game:GetService( "UserInputService" ).InputBegan:connect( function (inputobject,gameProcessedEvent) |
02 | --case |
03 | if inputobject.KeyCode = = Enum.KeyCode.Q then |
04 | local file = Instance.new( "ScreenGui" ) |
05 | file.Parent = game.Players.LocalPlayer.PlayerGui |
06 | local paper = Instance.new( "Frame" ) |
07 | paper.Size = UDim 2. new( 0 , 100 , 0 , 100 ) |
08 | paper.Visible = true |
09 | paper.Parent = file |
10 | end |
11 | end ) |