--------------------This is in a localScript
local detect = script.Parent.detect --this goes to an imageButton that is the child of a surfaceGui that is attacted to a block
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local mouseX
detect.MouseButton1Down:Connect(function()
mouseX = mouse.X
end)
detect.MouseButton1Up:Connect(function()
local diffX = mouseX - mouse.X
if diffX > 80 or diffX < -80 then
if diffX < 0 then
print("right")
mouseX = nil
elseif diffX >= 0 then
print("left")
mouseX = nil
end
end
end)
This works fine on PC. But on mobile, this will work but if I try again in the same direction as the previous, it will not work. Another issue that only happens on mobile is I can just click on either side of the surfaceGui without dragging and it will still run.