I am learning how to use the Context Action Service. I have a script that should print "spacewaspressed" when you press space or if you are on mobile when the button is pressed. I have a local script in starter player. Here is my script:
local contextActionService = game:GetService("ContextActionService")
contextActionService:BindAction("Boost", spacepressed, true, Enum.KeyCode.Space)
function spacepressed()
print("spacewaspressed")
end
When start the game I get "Argument 2 missing or nil" on line 3. Argument 2 is the function it is supost to fire and its spelled right so idk. Its probably something really simple that I missed but I am a beginner scripter so yeah... Thanks :D
I tried a new script that should work but it still isn't and I am getting nothing in output.
local contextActionService = game:GetService("ContextActionService")
function SpacePressed()
print("spacewaspressed")
end
contextActionService:BindAction(
"Boost",
SpacePressed,
true,
Enum.KeyCode.Space
)

4 comments
oh rip xD thanks
oh, was about to say it doesn't work
ok thanks
hmm... As I said I am a beginner scripter and I don't really under stand "(string, inputstate, inputobject)". In the examples on the wiki they just put the name of the function. Please help :D