Hello! Before I added ContextActionService to my inventory system, it worked just fine when I clicked it. Now, when I click on the inventory button, it no longer opens; but if you use ContextActionService, it works fine. Can you help?
local function OpenInventory(ActionName, InputState, InputObject)
if InputState == Enum.UserInputState.Begin then
game.Players.LocalPlayer.PlayerGui.Sounds.Click4:Play()
game.Players.LocalPlayer.PlayerGui.Inventory.Frame.Visible = not game.Players.LocalPlayer.PlayerGui.Inventory.Frame.Visible
end
end
script.Parent.MouseButton1Click:Connect(OpenInventory)
local ContextActionService = game:GetService("ContextActionService")
ContextActionService:BindAction("OpenInventory", OpenInventory, false, Enum.KeyCode.Backquote, Enum.KeyCode.X)
local function OpenInventory(ActionName, InputState, InputObject)
game.Players.LocalPlayer.PlayerGui.Sounds.Click4:Play()
game.Players.LocalPlayer.PlayerGui.Inventory.Frame.Visible = not game.Players.LocalPlayer.PlayerGui.Inventory.Frame.Visible
end
script.Parent.MouseButton1Click:Connect(OpenInventory)
local ContextActionService = game:GetService("ContextActionService")
ContextActionService:BindAction("OpenInventory", OpenInventory, false, Enum.KeyCode.Backquote, Enum.KeyCode.X)