Hello. I am trying to set up mobile support for my game and I am having an issue.
What I want is to detect holding and releasing the mobile button (created by contextactionservice) but it is not working. Here is the code:
local connection
local function leftClick()
local db = false
UIS.InputBegan:Connect(function(input)
if db then return end
if input.UserInputState == Enum.UserInputState.Begin then
MouseLeftClick.Value = true
db = true
task.delay(.1, function()
db = false
end)
connection = input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
MouseLeftClick.Value = false
db = true
task.delay(.1, function()
db = false
end)
connection = nil
end
end)
end
end)
end
CAS:BindAction("L", leftClick, true)
CAS:SetTitle("L", "L")
Right now, it actually detects hold and release, but after I hit the button once, it starts to take ANY action as holding down the button, like touching the screen to walk. How can I fix that?