Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can This Function Be an Anonymoose Function?

Asked by 6 years ago

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

Log in to vote
1
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

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)
0
Oh cool, thanks GatitosMansion 187 — 6y
Ad

Answer this question