local Player = game.Players.LocalPlayer gui = .Parent Mouse = Player:GetMouse Open = False end function PressM(Key) if (key == "m") then if (Open == false) then gui.MenuPart.Visible = true Open = true elseif (Open == true) then gui.MenuPart.Visible = false Open = false end end end
Mouse.KeyDown:connect(PressM)
I don`t know why this is not working. Anyone have suggestions?
Here you go, it was largely working, but there were just a few mistakes that I've fixed for you. You should have caught these yourself, though. Have you enabled script analysis and console output? If not, do. They're extremely useful for debugging scripts like yours. Also, PLEASE use a code block next time for your code.
The fixed code:
local Player = game.Players.LocalPlayer Mouse = Player:GetMouse() gui = --pointer to your player's screenGui Open = false function PressM(key) if (key == "m") then if (Open == false) then gui.MenuPart.Visible = true Open = true elseif (Open == true) then gui.MenuPart.Visible = false Open = false end end end Mouse.KeyDown:connect(PressM)
Explanation: All you had wrong was some parentheses missing from the GetMouse function, which you could have easily debugged yourself. Again, script analysis and console is a must! A possible second reason is that you may have put this into a script, instead of a localscript, which would break the code as soon as you started a server. If you haven't already, put it into a localscript, inside of either the player's starterScripts or starterGui.
Hope this helped!