I have a question for BindActionAtPriority when the lower proprieteies level gonna execute

for example here


the lowest never execute

This is an example from the DevHub. Apparently it is meant as it is, and it sinks input in the first function so that the other one doesn’t run.

Lower number means lower priority. If Enum.ContextActionResult is not explicitly returned in your code, it is returned implicitly as Sink.

If we use BindAction, action that was bound to the same key code last also has the highest priority.

And as the comments in the script say, BindActionWithPriority means that the provided numbers instead of order of binding will determine the priority order. We could bind an action with higher priority before an action with lower priority and vice versa.

Modified script
local ContextActionService = game:GetService("ContextActionService")

local function handleThrow(actionName, inputState, inputObj)
	if inputState == Enum.UserInputState.Begin then
		print("Throw")
		return Enum.ContextActionResult.Sink
	end
end

local function handlePunch(_, inputState, _)
	if inputState == Enum.UserInputState.Begin then
		print("Punch")
		return Enum.ContextActionResult.Pass
	end
end

ContextActionService:BindActionAtPriority("PriorityThrow", handleThrow, false, 2, Enum.KeyCode.Q)
ContextActionService:BindActionAtPriority("PriorityPunch", handlePunch, false, 1, Enum.KeyCode.Q)

ContextActionService:BindActionAtPriority("PriorityThrow2", handleThrow, false, 1, Enum.KeyCode.E)
ContextActionService:BindActionAtPriority("PriorityPunch2", handlePunch, false, 2, Enum.KeyCode.E)

Pressing Q:

Throw has higher priority than punch, and handleThrow sinks input, so handlePunch is not called despite being next in line (at a lower priority).

Pressing E:

This time punch has higher priority than throw, and handlePunch passes input, which allows handleThrow to run afterwards.