I have a script for my inventory GUI. it requires you to either press the Open/Close Inventory button or Press F. Below is a serverscript for the button
01 | local frame = script.Parent.Parent.Inventory |
02 | local UserInputService = game:GetService( "UserInputService" ) |
03 |
04 | function OpenOrClose() |
05 | if frame.Visible = = false then -- Checks to see if it is open or closed |
06 | frame.Visible = true -- Opens the GUI |
07 | elseif frame.Visible = = true then -- Checks to see if it is open or closed |
08 | frame.Visible = false -- Closes the GUI |
09 | end |
10 | end |
11 |
12 | script.Parent.MouseButton 1 Click:Connect( function () |
13 | if frame.Visible = = false then |
14 | frame.Visible = true |
15 | elseif frame.Visible = = true then |
The button works except when I press F, it doesn't open or close. Can anyone tell me why?
If i'm correct you need to set the Gui as the Player Gui.
I hope you know how to do that, before asking how to do that if you don't know search on google first for some tutorials.
If not comment down below and I'll do my best to help.
The only possible way that I can see why your code doesn't work is that "UserInputService" only works in Localscripts. Most likely, you've written your code in a Serverscript. If this doesn't work, well then I don't know.