The input began event does not work properly with image buttons

CloseButton.InputBegan:Connect(function(Input)	
if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then
		IsPressed = true
	end
end)`

When I used the code above the image button was not working on mobile devices

CloseButton.MouseButton1Down:Connect(function()
	IsPressed = true
end)

however, when i changed it to the old MouseButton1Down event it worked find, is this a glitch in the system or am i doing something wrong

If CloseButton is a image button you should try using .Activated so basically it’d be something like this;
CloseButton.Activated:Connect(function()
IsPressed = true
end)
You can get more info on this here; GuiButton | Documentation - Roblox Creator Hub
.Activated works with PC, devices and console btw

activated still doesnt work, btw i am using the emulator to test my mobile configurations