Why won't the ScreenGui appear?

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	
	plr:WaitForChild("PlayerGui").ScreenGui.Enabled = true
end)

I am trying to make a tiny keyboard that when you press a certain key, it brings up a ScreenGui, the ScreenGui, in this case, does not pop up, and there are no errors.

What could I have done wrong?

1 Like

Is it in the starter gui and is it enabled?

1 Like

The ScreenGui is in StarterGui and it is not enabled, that’s why the script enables it.

1 Like

There are few possibilities on your problem.

  1. The GUI object is not present on PlayerGui Model
  2. The GUI object is on the client but not shown on the server
  3. You might be referring to the wrong GUI

Solutions

  1. Make sure the GUI object is in the PlayerGui Model
  2. Make sure the GUI is also shown on the server
  3. Check the name of the GUI object
  4. But lets say the solutions above didnt work, you have everything in place and correctly.
    Try this code then
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	
	plr:WaitForChild("PlayerGui"):WaitForChild("ScreenGui").Enabled = true
end)
3 Likes

is the GUI on the server side? or the client? Also is the click script on the client side?

1 Like

The click script is a local script under the button.

1 Like

You said certain key, Right? Your script activates whenever you click the clickdetector mentioned it. If you want to detect keypresses, use UserInputService!

Else, if you wanted to detect clicks on a specific part, continue on what you are doing

3 Likes

I have 3 suggestions.

  1. Make sure that this is a LocalScript. It is not possible to change the GUI via Script because the Gui is individual for each person.
  2. Don’t try to change StarterGui. You won’t be able to work with StarterGui. A bit of theory - Everything you do in StarterGui is duplicated in PlayerGui. And only PlayerGui can be changed via LocalScript. To access PlayerGui is possible only through a LocalScript. local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
    PlayerGui contains all the GUIs that you made in StarterGui.
  3. Instead of the Gui on/off operation, I advise you to change the Frame.Visible. This is a more optimized solution. Let ScreenGui be always enabled. And everything else that you want to add, add under the Frame.

Also i advice you to read about UserInputService

1 Like

Ahhh… local scripts dont work on workspace

1 Like

It’s a keyboard made with parts, not actual keys.

1 Like

I am confused are u using a GUI button event or a Click detector event?

1 Like

Click detector event… 30charss

1 Like

where is the click detector placed?

1 Like

Inside of a part (30charsssss)

1 Like

like in workspace? or starter gui

1 Like

Why would there be a click detector in starter gui? Or a part at most? Of course workspace.

1 Like

I just wanted to cross check

so show me what this code prints

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	for i,v in pairs(plr:WaitForChild("PlayerGui"):GetChildren()) do
              print(v.Name)
         end
end)
1 Like

I’m kind of confused because you said “when you press a certain key a gui pops up” but your doing a clickdetector? please explain more.

Did you put anything inside of the Screengui? If you didn’t then the that explains why. You need to put something inside the ScreenGui for something to appear on-screen. (A UI Object)

When you press a certain key on a keyboard, a keyboard made out of parts.