Cursor not aiming accurately for some players

During some of the recent ROBLOX updates, there have been reports from different players that their cursor isn’t accurately aiming where it’s meant to be. When the issue takes place, it’s a consistent issue until the next few ROBLOX updates, but there are some cases where players say it “fixes itself”?

I have listed two examples below for both a player who has accurate cursor aiming, and the other having an offset.

Here is how I handle the cursor logic:

  • Get the mouse X/Y coordinates using User Input Service’s :GetMouseLocation()
  • Use :ScreenPointToRay() on the player’s Camera to get a unit ray
  • Raycast from the unit ray’s origin and into the direction by a range to get a colliding object
  • Use :WorldToScreenPoint() on the player’s Camera to get the Distance between the player’s Camera and the colliding object

WORKING CURSOR
Clip:
YouTube

Specs:
OS - Windows 11
CPU - Intel(R) Core™ i9-14900KF
Memory - 32 GB
GPU - NVIDIA GeForce RTX 4080, 16 GB

Image:
image

CURSOR WITH OFFSET:
Clip:
YouTube

Specs:
OS - Windows 11
CPU - Intel i5-12400F
Memory - 16GB
GPU - NVIDIA GeForce RTX 3060

Image:
image

I’m unsure if this happens to other games, but as far as I know, this has been an issue in my game for months.
Game Link

I have also attached a snippet of the cursor logic if it helps

Expected behavior

All players should have an accurate cursor as seen in the first clip.

4 Likes

Thanks for you report, we are investigating this issue.

2 Likes

Thanks for reporting this issue! We investigated and couldn’t reproduce a raycast problem, but we did identify a couple of scripting scenarios that might explain what you’re seeing. We’d like to confirm that your code is set up correctly:

Scenario 1:


In the video, the mouse position (red) and target position (green) are shown, with distance displayed in text. A target is only valid if distance < 100. If no valid target exists and the previous result isn’t cleared, the last valid target may continue to appear, which can make it look like there’s an offset between the mouse position and the target position.

Expand to check the exact snippet used in the video demo:
local UserInputService = game:GetService("UserInputService")
local GuiService = game:GetService("GuiService")
local MousePoint = script.Parent.MousePoint
local Target = script.Parent.Target
local TextLabel = script.Parent.TextLabel

game:GetService("RunService").RenderStepped:Connect(function()
	local mouseLocation = UserInputService:GetMouseLocation()
	MousePoint.Position = UDim2.new(0,mouseLocation.X, 0, mouseLocation.Y - GuiService.TopbarInset.Height)

	local camera = workspace.CurrentCamera
	local unitRay = camera:ScreenPointToRay(mouseLocation.X, mouseLocation.Y - GuiService.TopbarInset.Height)
	local raycastResult = workspace:Raycast(unitRay.Origin, unitRay.Direction * 1000, RaycastParams.new())
	if raycastResult then
		local hitPos = raycastResult.Position
		local distance = (hitPos - camera.CFrame.Position).Magnitude
		local screenPoint, onScreen = camera:WorldToScreenPoint(hitPos)
		if math.floor(distance) < 100 then
			Target.Position = UDim2.new(0,screenPoint.X, 0, screenPoint.Y)
		end
		TextLabel.Position = UDim2.new(0,screenPoint.X+20, 0, screenPoint.Y)
		TextLabel.Text = math.floor(distance)
	end
end)

Scenario 2:
If the update function isn’t bound to RenderStepped to refresh every frame, there could be a timing mismatch between the visual update and the mouse/target position updates, which might also cause the issue.

Could you check your setup against these scenarios and let us know if the issue is still occurring in your game (especially since it’s been a long time passed)? Any additional details on how to reproduce it would also be helpful. Thanks!

We appreciate your patience. Unfortunately, we couldn’t identify the cause of the issue. We’re closing this report. Please re-open it if you have more details.