Need help on making my map open with a hotkey

Hi everyone,
I am by no means a scripter, so that is why I am reaching out. I am wondering if someone can help me out with making my open and close map button controlled by a hotkey. Thank you in all advance for all of your help. I will link the model I am using below. Thanks

Model

You can’t really ask for scripts to people, but here’s what I would do

First a localscript in starterplayerscripts

You need to do something with a hot key, meaning you have to bind something to a key, well, get the service ContextActionService which is used to bind actions to keys, define it with a variable (local context = game:GetService(“ContextActionService”))

You need to show a map, a map is an image shown in the hud, and the images shown in the hud are in the starter GUI section. Get the service starter GUI in the script

Make a local variable that is equal to false in the variable defining section. This is what we will use to check if it’s being opened or closed. Because in the beginning it’s closed, isopen (the variable) is false.

Call context that was defined in a variable and set :bindaction to it, follow the instructions to set the key that appears in the dev hub.

In startergui, add a screengui, and inside of it add an image layer, put the image you want and disable it.

Now, the objective of the context action service we called before is to check if the screen GUI we made is enabled or not, and if it’s in one, change it to the opposite.

Make a local function mapchange(_, state) which is the function that we will call so we don’t have to set the function on bindaction. This local function has on the first paragraph “if state == Enum.userinputstate.begin then”, because we need to know that the input of the key is starting, not ending (the game sends two signals in one bindactions, one when pressing and one when releasing). Inside the first if we did we put that if isopen is false then change that isopen value to true, and then, enable the screengui with the map. Elseif isopen = true, isopen = false and disable the map.

You’ll need to know how to use contextaction service and startergui. I’m not doing the script, you can figure things out I guess, it’s not that hard once you learn how to do it.

1 Like