ContextActionService inputTypes parameter

I tried to set it to Enum.KeyCode.Space and that didn’t work. I had to set it to " ". I should be able to set it to Enum.KeyCode.Space. It even says “Variant<string, KeyCode, UserInputType, PlayerActions>... inputTypes” in the wiki. It says KeyCode, so I tried giving it one. It didn’t work. It needed the actual space character.

code in question:

local signal = game.ReplicatedStorage.Bomb
local cas = game:GetService("ContextActionService")
cas:BindAction("bomb", function(_, state)
	if state.Name=="Begin"then
		signal:FireServer(true)
	elseif state.Name=="End"then
		signal:FireServer()
	end
end, false, Enum.KeyCode.Space)

That’s quite funky. cc @darthskrill

This is due to the default control script binding to space for jump as well. What happens is your script binds before the default script does. You can fix this by overriding the default control script, or if there is an appropriate time later to bind this action, it should happen after jump binds.

If you do bind over jump, however, your character will not be able to jump until you unbind the bomb action.

If you are interested in overriding the default camera and control scripts, this page about mobile controls has some details about it: Documentation - Roblox Creator Hub

So that means that Enum.KeyCode.Space and " " are being treated separately in the binding stack? That makes sense then.

you code do either and the result will be the same, but yes they would bind separately internally. I recommend sticking to one convention if possible (either enum or literals).

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.