Mobile Mouse Location is wrong

Well I think this clip speaks for itself.
The first one is on pc other one on ios Iphone XR

So for some reason there is some weird offset on the IPhone XR version. This messes up some ui elements in my game. Have anyone found a fix for this problem, it’s very weird to me that this occurs in the first place. Please help if you know anything.

The code is:

local UIS = game:GetService("UserInputService")
local mouse = game.Players.LocalPlayer:GetMouse()

mouse.Button1Down:Connect(function()
	local mouseLocation = UIS:GetMouseLocation()
	
	local frame = Instance.new("Frame")
	 frame.BackgroundColor3 = Color3.new(1, 0, 0)
	frame.AnchorPoint = Vector2.new(.5, .5)
	frame.Size = UDim2.fromOffset(50,50)
	frame.Position = UDim2.fromOffset(mouseLocation.X, mouseLocation.Y)
	frame.Parent = game.Players.LocalPlayer.PlayerGui.Popups
	
	game:GetService("Debris"):AddItem(frame, 4)
end)

Okay so I found a workaround to this issue.
Basically, Mouselocation does not check what insets you have.
So if you have insets disabled on iphone X for example, It would return the mouselocation as if those inset were there.

The workaround is having a separate screenGui with inset enabled, then create a frame there, get the absoluteposition of that frame and you have the correct position.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.