MouseButton1Down not working on mobile

Hi DevForum,
I’ve encountered an issue. Basically, I’m making a Heel UI where you can customise Heels and weld them to your feet. That all works perfectly. My issue is that upon testing my colour wheel (I’ll send a picture below) doesn’t seem to work on mobile. This is both a studio and an in-game issue. I’m not sure of the cause, maybe I haven’t enabled something that should be, not sure. I don’t know if it’s worth sending the script as I’m pretty sure it’s got something to do with the properties of the colour wheel. It’s probably a stupid mistake I am prone to them.

image

1 Like

you’re trying to use MouseButton1Down… on mobile… which doesn’t have a mouse?
that issue is quite self-explanatory.

Oh I meant, MouseButton1Click. My apologise

MouseButton1Down works on touch screen devices though.

1 Like

Thats what I thought aswell, hmm

hello,

more context is needed, please include your script.
can you also try using the mobile device under the test section in the top of studio, and see if the issue persists on there?

Yeah of course. I also mentioned above that It was also studio bug, my apologise if I wasn’t clear enough

function updateColour(CentreOfWheel)
	local ColourPickerCentre = Vector2.new(
		ColourWheel.Picker.AbsolutePosition.X + (ColourWheel.Picker.AbsoluteSize.X/2),
		ColourWheel.Picker.AbsolutePosition.Y + (ColourWheel.Picker.AbsoluteSize.Y/2)
	)
	local H = (math.pi - math.atan2(ColourPickerCentre.Y - CentreOfWheel.Y, ColourPickerCentre.X - CentreOfWheel.X)) / (math.pi * 2)
	local S = (CentreOfWheel - ColourPickerCentre).Magnitude / (ColourWheel.AbsoluteSize.X/2)
	local V = math.abs((DarknessSlider.AbsolutePosition.Y - DarknessPicker.AbsolutePosition.Y) / DarknessPicker.AbsoluteSize.Y - 1)
	local HSV = Color3.fromHSV(math.clamp(H, 0, 1), math.clamp(S, 0, 1), math.clamp(V, 0, 1))
	ColourDisplay.ImageColor3 = HSV
	_G.HeelsColour = ColourDisplay.ImageColor3
	DarknessPicker.UIGradient.Color = ColorSequence.new{
		ColorSequenceKeypoint.new(0, HSV), 
		ColorSequenceKeypoint.new(1, Color3.new(0, 0, 0))
	}
end

DarknessPicker.MouseButton1Click:Connect(OnDarknessPickerDown)
ColourWheel.MouseButton1Click:Connect(OnColourWheelDown)

UserInputService.InputChanged:Connect(function(input)
	if input.UserInputType ~= Enum.UserInputType.MouseMovement then return end
	local MousePos = UserInputService:GetMouseLocation() - Vector2.new(0, game:GetService("GuiService"):GetGuiInset().Y)
	local CentreOfWheel = Vector2.new(ColourWheel.AbsolutePosition.X + (ColourWheel.AbsoluteSize.X/2), ColourWheel.AbsolutePosition.Y + (ColourWheel.AbsoluteSize.Y/2))
	local DistanceFromWheel = (MousePos - CentreOfWheel).Magnitude
	if DistanceFromWheel <= ColourWheel.AbsoluteSize.X/2 and ButtonDown then
		WheelPicker.Position = UDim2.new(0, MousePos.X - ColourWheel.AbsolutePosition.X, 0, MousePos.Y - ColourWheel.AbsolutePosition.Y)
	elseif MovingSlider then
		DarknessSlider.Position = UDim2.new(DarknessSlider.Position.X.Scale, 0, 0, 
			math.clamp(
			MousePos.Y - DarknessPicker.AbsolutePosition.Y, 
			0, 
			DarknessPicker.AbsoluteSize.Y)
		)	
	end
	updateColour(CentreOfWheel)
end)

I believe mousebutton1click works on mobile but it’s really hard for the event to register the user tapping. You’re likely better off using mousebutton1down

Okay thank you so much, I’ll try now

The problem seems to persist. Perhaps, the location of the UI could interfer with stuff like character movement, maybe it’s in the area where the moving joystick thingy is and stuff like that

If it’s overlapping any of the primitive ui elements that may cause problems too

Have you tried GuiButton.Activated instead?

No I have not, I can try though.

Yeah still the same issue, I think @Kurookku suggest might be the cause

I think it could be this, I can try

EDIT: it doesn’t seem to be the issue…

Did you try removing if input.UserInputType ~= Enum.UserInputType.MouseMovement then return end?

Thank you so much. This wasn’t my script so I wasn’t that sure. Evidently, I hadn’t read through the script before making this post.

It doesn’t work because moving your finger on the touchscreen isn’t considered MouseMovement. Use this:

UserInputService.TouchMoved:Connect(function()
    -- player drags finger on touch
end)

It’s working for me, ummmmmmmm