local function Menu(actionName, inputState, _inputObject)
if actionName == "OpenMenu" then
script.Parent.Enabled = true
Services.CS:AddTag(Player.Player, "InMenu")
Tweens.OpenTween:Play()
elseif actionName == "CloseMenu" then
Tweens.CloseTween:Play()
Services.CS:RemoveTag(Player.Player, "InMenu")
script.Parent.Enabled = false
end
end
Services.UIS.InputBegan:Connect(function(input, isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.M and Player.Player:HasTag("InMenu") then
Services.CAS:BindActionAtPriority("CloseMenu", Menu, true, 0, Enum.KeyCode.M)
warn("close")
elseif input.KeyCode == Enum.KeyCode.M and not Player.Player:HasTag("InMenu") then
Services.CAS:BindActionAtPriority("OpenMenu", Menu, true, 0, Enum.KeyCode.M)
warn("open")
end
end)
local function Menu(actionName, inputState, _inputObject)
if actionName == "OpenMenu" then
script.Parent.Enabled = true
Services.CS:AddTag(Player.Player, "InMenu")
Tweens.OpenTween:Play()
elseif actionName == "CloseMenu" then
Tweens.CloseTween:Play()
Services.CS:RemoveTag(Player.Player, "InMenu")
script.Parent.Enabled = false
end
end
local function BindActions()
-- Unbind previous actions
Services.CAS:UnbindAction("OpenMenu")
Services.CAS:UnbindAction("CloseMenu")
-- Bind new actions
if Player.Player:HasTag("InMenu") then
Services.CAS:BindActionAtPriority("CloseMenu", Menu, true, 0, Enum.KeyCode.M)
warn("close")
else
Services.CAS:BindActionAtPriority("OpenMenu", Menu, true, 0, Enum.KeyCode.M)
warn("open")
end
end
BindActions()
Services.UIS.InputBegan:Connect(function(input, isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.M then
BindActions()
end
end)
local function Menu(actionName, inputState, _inputObject)
if actionName == "OpenMenu" then
script.Parent.Enabled = true
Services.CS:AddTag(Player.Player, "InMenu")
Tweens.OpenTween:Play()
elseif actionName == "CloseMenu" then
Tweens.CloseTween:Play()
Services.CS:RemoveTag(Player.Player, "InMenu")
script.Parent.Enabled = false
end
end
local function BindActions()
if Player.Player:HasTag("InMenu") then
Services.CAS:UnbindAction("OpenMenu")
Services.CAS:BindActionAtPriority("CloseMenu", Menu, true, 0, Enum.KeyCode.M)
warn("close")
else
Services.CAS:UnbindAction("CloseMenu")
Services.CAS:BindActionAtPriority("OpenMenu", Menu, true, 0, Enum.KeyCode.M)
warn("open")
end
end
BindActions()
Services.UIS.InputBegan:Connect(function(input, isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.M then
BindActions()
end
end)
Alright so I have tried following the issue, and I noticed that the menu function never receives the “CloseMenu” action name. (EDIT: It has something to do with the Tags)