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

Can This Function Be an Anonymoose Function?

I was just wondering if this function can be converted into an anonymouse function, is it possible? I'm thinking no, but I could be wrong.

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)

If you don't know what an anonymous function is, it looks something like this:

game.workspace.Part.Changed:Connect(function()
	print ("A-non-moose")
end)

1 answer

✓ Accepted answer

Yes, it can.

game.ContextActionService:BindAction("keyPress", function(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then
        print("R was pressed")
    end
end, false, Enum.KeyCode.R)

1 comment

0

Oh cool, thanks

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