Ad
Log in to vote
0

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

Asked by
pocvq 0
3 days ago
Edited 3 days ago

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

Log in to vote
0
Answered by 3 days ago
Edited 3 days ago

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.

Ad

Answer this question