So, I’m creating a Gun. It works like any other and reloads when the “R” key is pressed, however in my tests I found something that shouldn’t happen:
As shown, when I pressed the Settings button, it reloaded and I don’t know why.
I’m using ContextActionService to get the keyboard of the player and connect it to a function, see the line that does it:
ContextactionService:BindAction(ACTION_RELOAD, reload, false, Enum.KeyCode.R) --//Reload on R key press
I tested it and apparently it happens because of ContextActionService.
Well, I guess there isn’t much to comment on with the 1 line of code you sent. assuming Action_Reload is a variable for the name of the action, there isn’t really anything wrong with what you’ve got. I wouldn’t assume there are any other parts of your script that would weirdly cause the reload() function to run when you click on settings, so it probably is safe to assume this is a glitch. If you do have any other part of your script which runs reload(), make sure that it is not somehow being tied up with clicking on the settings icon.
Was this text copied directly from your code? There are some typos.
ContextactionService:BindAction(ACTION_RELOAD, reload, false, Enum.KeyCode.R) --//Reload on R key press
.
.
.
I tried using ContextActionService and binding R, and it did not bring up the menu (though I’m on a Mac). Did you import any code or anything? Try walking through your code with the debugger.
Then ye, it’s probably safe to assume it’s a glitch. Perhaps it ends up having something to do with the fact that you press R to respawn once you open up the settings menu, so Roblox somehow tied that into the contextactionservice or whatever. Try changing the key code to something like Enum.KeyCode.P-- one which does not appear in the settings menu and see if this glitch still happens (not that you’d keep it this way, just a way to see if it is related to the R key specifically or any key)
I tested changing from Key"R" to key “P” and nothing happened. Probably what you said is happening, because as ContextactionService bind an action to user input, it must have confused or something, but I don’t know how to solve this
Welp, in that case yeah, it does likely have to do with the fact that R is a hotkey on the settings menu. What you should do is report this as an Engine bug in platform feedback.
For the time being, though, it’s probably not too big of an issue since this is not a bug which will affect your gameplay by any substantial amount.
I’m thinking the same thing. See if UserInputService doesn’t get triggered by the settings icon (I don’t think it does), and if not, then it’ll be a good fix for your issue.