Key not opening GUI

so im trying to make a key open a GUI but it doesnt seem to work.
here is the code:

local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input)
	if input == Enum.KeyCode.C then
		if script.Open.Value == false then
			script.Parent.Parent.BagGUI.Visible = true
		elseif script.Open.Value == true then
			script.Parent.Parent.BagGUI.Visible = false
			script.Open.Value = false
		end
	end
end)

“input” is an input object that has info about a user’s input, it isn’t just the key code. If you want to compare the key code then do

if input.KeyCode == Enum.KeyCode.C then

https://developer.roblox.com/en-us/api-reference/class/InputObject

2 Likes

thanks, i forgot to put .KeyCode infront of input