Help pls about screen center cursor?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
  • i want to like have accurate raycast to a cursor in the middle of the screen for
    mobile players on third person


  1. What is the issue?
  • i tried raycasting from the screen to get a position so the hitscan gun can shoot,
    but the ray isnt accurate to the cursor’s position
  1. What solutions have you tried so far?
  • i tried adding “camera.Cframe *” but it doesnt work and
    honestly i dont know any more way to “fix” this issue i have

Hi, you want to have the position of the frame like this ?:

Try this script:

--[[ Local Script ]]--
local RunService = game:GetService("RunService")

local Camera = game.Workspace.CurrentCamera
local Frame = script.Parent

local part ="Part")
part.Parent = game.Workspace
part.Anchored = true
part.Size =, 2, 2)
part.Color =, 0, 0)

local raycastParams =
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.FilterDescendantsInstances = {part}

	local position = Frame.AbsolutePosition
	local size = Frame.AbsoluteSize
	local unitRay = Camera:ScreenPointToRay(position.X + size.X/2, position.Y + size.Y/2)
	local raycastResult = game.Workspace:Raycast(unitRay.Origin, unitRay.Direction * 1000, raycastParams)
	local frameWorldSpace = raycastResult and raycastResult.Position or unitRay.Origin + unitRay.Direction * 1000
	part.Position = frameWorldSpace


If you want just have the position of the frame and not the part following, just delete “local part” and others! (sorry for mistakes, im french)


oh, sorry for the late “solution” thing i didnt actually think someone would give me one, ive scrolled around devforum and found 2 and i thought of doing it.

you, sir. are a life saver. thank you

1 Like

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