How do i bind a key to a function

i dont have any relevant code but this should give a idea what what I’m trying to do


if key.KeyCode == ??? then
//other code
end)

I just cant make key work
can someone help me with this
I will then put my functions in other code

is this what you mean?

game:GetService("UserService").InputBegan:Connect(function(Input, GPE)
	if Input.KeyCode == Enum.KeyCode.F then
		--code blah blah
	end
end)
2 Likes

You can also use ContextActionService:BindAction to bind a function to a key

4 Likes