I’m trying to figure out how to check when the ContextActionService button is being held. If you don’t know what it is, it’s this.
I want to create a simple “while true do” loop of when the button is held but I can’t seem to find the right thing to do that.
Thanks for stopping by to read!
Just create a variable that changes when the button is pressed/unpressed, and refer to that in your loop.
Example:
local ContextActionService = game:GetService("ContextActionService")
local pressedvar = false
local function pressedfunc(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Begin then
pressedvar = true
else
pressedvar = false
end
end
ContextActionService:BindAction("Interact", pressedfunc, true, "your button")
while true do
if pressedvar == true then
--do whatever
end
end