Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Problem with opening a GUI with a keyboard character in this case "m" can someone help?

local mouse = game.Players.LocalPlayer:GetMouse() local gui = script.Parent.ScreenGUI.Frame

mouse.KeyDown:Connect(function(key) if key == "m" then gui.Visible = not gui.Visible end end)

that is my script anyways its not working I dont know why but if someone can help it would be nice it also says in the output ScreenGUI is not a valid member of Players.pocvq.PlayerGui

1 answer

Try this:

local Player = game:GetService("Players").LocalPlayer
local mouse = Player:GetMouse()
local PlayerGUI = Player:WaitForChild("PlayerGui")
local gui = PlayerGUI.ScreenGUI.Frame

mouse.KeyDown:Connect(function(key)
	if key == "m" then
		gui.Visible = false
	end
end)

Sometimes the script runs faster than the assets.

This discussion is preserved as it was. New answers, comments, and votes are closed.