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)

3 comments
add a debounce if you hold it the deboune = false and if you not hold it it sets it to true
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
debounce can be at any speed so