How to detect continous touched event in mobile?

How to detect continous touched event in mobile?

please, be more specific, what you mean with touched event in mobile? you are asking how to check if a player is pressing a gui button continuous?

Yes I asking how to check if player presseing gui button continous.

local GuiButon = pathToGuiButton

local PressingButton = false


task.spawn(function()
    while true do -- Every loop inside spawn doens't stop the rest of script outside of the pcall.
        if PressingButton then
            -- your script here
        end

        task.wait()
    end
end)

GuiButon.MouseButton1Down:Connect(function() -- this works for mobile too
    PressingButton = true
end)

GuiButon.MouseButton1Up:Connect(function()
    PressingButton = false
end)

better explanation of what task.spawn do

1 Like