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

[Solved] Why does my ContextACtionService mobile button keep spamming when i hold it down?

Asked by 2 years ago
Edited 2 years ago

ive set up a simple ContextActionService mobile button to change between classic camera and locked in first person camera, for whatever reason no matter what button I try to create when I hold it down or even try to quickly tap it, it just keeps spamming it making it completely useless considering if I want to for example toggle a flashlight I cant do that because it keeps going on and off very fast. here's my code:

local plr = game.Players.LocalPlayer

local cAS = game:GetService("ContextActionService")

local firstP = false


local function handleAction(actionName, inputState, inputObject)
    firstP = not firstP
    print("Changed 1st person to "..tostring(firstP))
    if firstP then
        plr.CameraMode = "LockFirstPerson"
    else
        plr.CameraMode = "Classic"
    end
end

-- Bind action to function
cAS:BindAction("ChangeCameraMode", handleAction, true, Enum.KeyCode.Tab)

0
add a debounce if you hold it the deboune = false and if you not hold it it sets it to true NEILASc 84 — 2y
0
good enough i guess, id rather not limit the speed at which the player can press on mobile etc but since roblox apparently cant even do buttons correctly i may either add the debounce thing or just make my own buttons with GUIs EiOooAxea 70 — 2y
0
debounce can be at any speed so NEILASc 84 — 2y

Answer this question