Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't my user input service script working?

local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input)
	local key = input.KeyCode
	if key == Enum.KeyCode.F then
		print("hmm")
	end
end)

soo here is my script. it's parented to the workspace and it's a local script and i can't see where the error is. could i please get some help?

1 answer

✓ Accepted answer

Here's the script.

My apologies for not explaining, in a rush.

function onKeyPress(actionName, userInputState, inputObject)
	if userInputState == Enum.UserInputState.Begin then
		print("R was pressed")
	end
end
 
game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.R)
-- The above line could also been written as:
-- game.ContextActionService:BindAction("keyPress", onKeyPress, false, "r")

1 comment

0

thanks ill try this in a second and then ill accept your answer

This discussion is preserved as it was. New answers, comments, and votes are closed.