hey everyone, so I’m trying to make a GUI that opens/closes when the player pushes “F”,
but don’t really know how to use ContextActionService. Solutions?
local CAS = game:GetService("ContextActionService")
local inventory = script.Parent
local function inventoryOpen()
inventory.Visible = true
end
local function inventoryClose()
inventory.Visible = false
end
while true do wait(.1)
if inventory.Active == false then
CAS:BindAction("inventoryActivate", inventoryOpen, false, Enum.KeyCode.F)
elseif inventory.Active == true then
CAS:BindAction("inventoryDeactivate", inventoryClose, false, Enum.KeyCode.F)
else
warn("Error")
end
end
local player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input,gameProcessedEvent)
if gameProcessedEvent then return end
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.F then
player.PlayerGui.OpenclosingGui.Frame.Visible = not player.PlayerGui.OpenclosingGui.Frame.Visible
end
end
end)