ContextActionService (Not being able to find out if UserInputState.End)

  1. What do I want to achieve?
    I want to be able to find out if a user is holding the button down or if it has been released.
    So using ContextActionService, if the user is on mobile/tablet it creates a button called Roll. Then when the user pressed that button it activated the Roll Function. However, when the user lets go it is supposed to unbind the function and stop it.

  2. What is the issue?

function Roll(name,input, object)
    if input ~= Enum.UserInputState.Begin then return end
    if plr.Character.Humanoid or plr.Character:WaitForChild("Humanoid") then
        if db == false then
            db = true
            if input == Enum.UserInputState.Begin then
                while input == Enum.UserInputState.Begin do
                    cumra.FieldOfView = 85
                    walk.SoundId = RollIdClone
                    walk.PlaybackSpeed = 1
                    rollAnimLoaded:Play()
                    dP:FireServer(plr)
                    wait(1)    
                    rollAnimLoaded:Stop()
                end
            elseif input == Enum.UserInputState.End then
                cumra.FieldOfView = 70
                rollAnimLoaded:Stop()
                walk.SoundId = WalkId
                walk.PlaybackSpeed = 1.85
            end
            db = false
        end
    end
end
ContextAction:BindAction("roll", Roll,true)
ContextAction:SetTitle("roll","Roll")
ContextAction:SetPosition("roll",UDim2.new(0.72,-105,0.6,-25))
ContextAction:UnBindAction("roll")

It seems to get stuck on the UserInputState.Begin

  1. What solutions have you tried so far?
    I have tried looking at the developer hub, discord chat, and more. However, I can’t seem to debug this.
1 Like

Also check your console? UnBindAction is not a valid member of ContextActionService, UnbindAction is though. The way it’s set up in your code though will just Bind and Unbind it straight away, making this all effectively pointless overall.

Hey, so the quoted part above is one of the things that was causing it not to work, the second being that of what you stated with the unbind and binding being pointless together.