This is a local script that is in parent with with a frame and now I wanted to add a keyinput that if I press M then it closes or opens the GUI, but it doesnt work. The mouse button click works fine but the key input doesn't.
local map = script.Parent.Parent.MinimapFrame
local button = script.Parent
button.MouseButton1Click:Connect(function()
if map.Visible == true then
map.Visible = false
button.Text = "Open Map"
else
map.Visible = true
button.Text = "Close Map"
end
end)
local userInputService = game:GetService("UserInputService")
userInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.M then
if map.Visible = true then
then map.Visible = false
else if map.Visible = false then
map.Visible = true
end
end
end
end
end)

2 comments
Thanks for accepting my answer!
No worries, glad that you could help me.