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

How do I change the visibility of a GUI with a keyboard input?

Asked by
Osamiku 12
4 years ago
Edited 4 years ago

I've wrote a previous script before this one and both haven't worked for me. The script and input runs through and does the print("") function but the GUIs disappear.

I've tried everything I could and nothing seems to work so I'm asking for help here.

Here is the script:

01-- Main Variable --
02 
03local Menu = game.StarterGui.ScreenGui.MenuGUI
04local plr = game.Players.LocalPlayer
05 
06-- Sub Menu Variables --
07 
08local Profile = Menu.Profile
09local Friends = Menu.Friends
10local Messages = Menu.Messages
11local Location = Menu.Location
12local Settings = Menu.Settings
13 
14-- Profile Image Variable --
15 
View all 32 lines...

All of the variables are organized and I've made sure that they were correct but I've tried changing inputs and making it a thing that happens when joining but it doesn't work.

I was trying to link a link to the image of the folder but I can't figure out how to so bear with me please

0
Why are you allocating UIS, then using a deprecated input-detection method...? Ziffixture 6913 — 4y
0
Also, StarterGui is a replication container. The GUIs are shifted into individual folders in each Client called "PlayerGui". You can reference this through the LocalPlayer Object. Ziffixture 6913 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
01local UIS = game:GetService("UserInputService")
02 
03UIS.InputBegan:Connect(function(K, playerIsChatting)
04 
05if K.KeyCode == Enum.KeyCode.E then
06if not playerIsChatting then
07 
08    Profile.Visible = false -- hide gui
09        Friends.Visible = false -- hide gui
10 
11        print("Menu GUI Deactivated")
12 
13        end
14    end
15end)
Ad

Answer this question