Mouse.Hit.Position on Mobile Inaccurate

Basically my problem is when I click in spots on mobile the mouse.Hit.p location is the last clicked spot instead of the recently clicked spot.

For example:

Click1 I click the world position 1,1,1
Click2 I click the world position 2,2,2
Click3 I click the world position 3,3,3

When I tap for the 2nd time (click 2) the Mouse.hit.p will be 1,1,1

https://gyazo.com/3765ec88d3906fb9e9040cc2ac9ee523

game.Players.LocalPlayer:GetMouse().Button1Down:Connect(function()
local par = Instance.new("Part")
par.Parent = game.Workspace
par.Position = game.Players.LocalPlayer:GetMouse().Hit.p
end)
1 Like

is it possible that its cuz of the emulator

I am also having the same problem but I can’t get to fix it.

Try using user input instead of mouse hit pos for the thing
Idk if this will work but something along this line?

local UserInput = game:GetService("UserInputService")
UserInput.TouchTap:Connect(function(touchPositions, gameProcessedEvent)
	local Cam = workspace.CurrentCamera;
	local RayLength = 500; --Idk some decent amount;
	local unitRay = Cam:ScreenPointToRay(touchPositions[1].X, touchPositions[1].Y);
	local ray = Ray.new(unitRay.Origin, unitRay.Direction * RayLength);
	--Insert part;	
	local part = Instance.new('Part');
	part.Anchored = true;
	part.CFrame = CFrame.new(ray.Origin, ray.Origin + ray.Direction);
	part.Parent = workspace;
end)

https://gyazo.com/e755726c1f4f0536b1ee2a32a63485c8

So I think I fixed it?

local UserInput = game:GetService("UserInputService");
UserInput.TouchTap:Connect(function(touchPositions, gameProcessedEvent)
	local Cam = workspace.CurrentCamera;
	local RayLength = 500; --Idk some decent amount;
	local unitRay = Cam:ScreenPointToRay(touchPositions[1].X, touchPositions[1].Y);
	local ray = Ray.new(unitRay.Origin, unitRay.Direction * RayLength);
	local _, Pos = workspace:FindPartOnRay(ray, game.Players.LocalPlayer.Character);
	--Insert part;	
	local part = Instance.new('Part');
	part.Anchored = true;
	part.Position = Pos;
	part.Parent = workspace;
end)
1 Like