Hi!
Recently, I learned how to use the UserInputService.
But, that’s not compatible with Mobile.
The docs are very confusing on the ContextActionService, how would I use to to toggle a frame?
Thanks!
Hi!
Recently, I learned how to use the UserInputService.
But, that’s not compatible with Mobile.
The docs are very confusing on the ContextActionService, how would I use to to toggle a frame?
Thanks!
local ContextActionService = game:GetService("ContextActionService")
local TOGGLE_FRAME_ACTION_NAME = "ToggleFrame"
local TOGGLE_FRAME_INPUT_TYPE = Enum.Keycode.F -- just an example
local frame = -- the frame
local function toggleFrame()
frame.Visible = not frame.Visible
end
local function handleAction(actionName, inputState, inputObject)
if actionName == TOGGLE_FRAME_ACTION_NAME and inputState == Enum.UserInputState.End then
toggleFrame()
end
end
ContextActionService:BindAction(TOGGLE_FRAME_ACTION_NAME, handleAction, true, TOGGLE_FRAME_INPUT_TYPE)
I forgot that the enum is UserInputState, not InputState. I’ve fixed that now.