How to get inputobject.position on console?

Right now i’m trying to add console compatibility onto my game and i’m testing it with a PS4 controller on the ROBLOX app on microsoft store However I have a problem. The problem isn’t the registering of the userinput, it registers the trigger,

The problem is: It seems that the Console player’s “cursor” is pointing elsewhere and not in the direction of the camera’s lookvector. (Shift lock is forced in my game)

userinputservice.InputChanged:Connect(function(input, gameprocessedevent)
	if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.None then
		GrabHandler:ItemUpdate(input.Position.X, input.Position.Y)
		CameraHandler:InputUpdate(input.Position.X, input.Position.Y)
--On console, input.X and input.Y both return something like -0.84563 some small
--number, While on PC both return normal values, 960 ish (middle of screen)


Head Faces Mouse


Player is looking off to the left always.


I’m pretty sure it’s because with a mouse as the input type the X/Y coordinates are relative to the screen.

The “MouseMovement” UserInputType will fire for whichever input device is considered the “mouse”. In the case of an Xbox controller it’d be one of the thumbsticks. (It depends on your settings I’m fairly sure.) Therefore, the input X/Y would show the position of the thumbstick, which is between -1 and 1 on each axis respectively. (Full circle.)

This might help:

1 Like

Thank you for replying! How exactly would i implement it into my script though as I only want to get the equivelant of inputobject.position of PC on Console

As you can’t use the MouseMovement input event similarly as you would on PC, maybe UserInputService:GetMousePosition() might work? If it doesn’t (I assume it doesn’t, but worth a try), then the only alternative I can think of is using the camera position & lookVector directly.


So i have it almost working.

function GetTarget()
	local NewRay =, camera.CFrame.LookVector)
	local Target = workspace:FindPartOnRay(NewRay, game.Workspace.TargetFilter)
	return Target

This is not working for me

CFrame.LookVector is a unit vector so it’s length is always 1, the direction of the ray also encodes the length of the ray. So in your case it’d only cast one stud into the direction of the LookVector.

Something like this should work:

local NewRay =, camera.CFrame.LookVector * 300)

That would cast a ray 300 studs into the LookVector’s direction, you can change that to suit your needs.

1 Like

Ah yes, it works now. Thanks for teaching and helping me!

1 Like

No problem and good luck with porting!

One last thing sorry, I’ve tested it and the cursor seems offset:

The head doesn’t follow the camera and highlighting the object doesn’t work either (The grabbing of the object does however
What’s going on here?

How are you using the GetTarget function exactly?

like this for the highlighting of the object:

function GrabHandling:ItemUpdate()
	if grabbing == false then
		local Target = GetTarget()
		if Target and Target.Parent:IsA("Model") and Target.Parent.PrimaryPart then
			if Target.Parent:FindFirstChild("Grabbable")  then
				if (plr.Character.PrimaryPart.Position - Target.Parent.PrimaryPart.Position).Magnitude < dist * 1.2 and not Target.Parent.PrimaryPart:FindFirstChild("IsGrabbed") then
					if highlightobject and Target.Parent.Outline ~= highlightobject then
						highlightobject.Transparency = 1
					highlightobject = Target.Parent.Outline
					highlightobject.Transparency = 0
				if highlightobject then
					highlightobject.Transparency = 1
			if highlightobject ~= nil then
				highlightobject.Transparency = 1

and like this for the camera:

function CamHandling:InputUpdate()
		local LookPoint = GetMousePoint()
	    local CameraDirection = Root.CFrame:toObjectSpace(LookPoint).lookVector
		if Neck then
			if Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
	        	Neck.C0 = CFNew(0, YOffset, 0) * CFAng(0, -asin(CameraDirection.x), 0) * CFAng(asin(CameraDirection.y), 0, 0)
			elseif Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
				Neck.C0 = CFNew(0, YOffset, 0) * CFAng(3 * math.pi/2, 0, math.pi) * CFAng(0, 0, -asin(CameraDirection.x)) * CFAng(-asin(CameraDirection.y), 0, 0)

GetMousePoint function is the gettarget function

Did you check if GetTarget returns the object you’re looking at? Try putting this in one of the functions:

local target = GetTarget()
print(target, target and target.Parent or nil) 

This should print the target’s name and the name of the parent if the target exists, else nil.

It returns something for the PC user but not for the console user not even “Nil”

Aight, so the issue still lies in the GetTarget() logic. Might have something to do with the cursor being offset. Any idea what’s going on with that? Does it only happen on console (or PC) or both?

The cursor offset is only happening on the console, Shift lock is forced on my game if that helps

Ah, yeah so, when using shift lock the camera’s position will be offset from the center. What you could try to do is use:

Use the center of the screen as the coordinates, and 300 as your depth/length of the ray (or any other number that you see fit), so something like this:

function GetTarget()
    local viewportSize = camera.ViewportSize
	local NewRay = camera:ScreenPointToRay(viewportSize.X / 2, viewportSize.Y / 2, 300)
	local Target = workspace:FindPartOnRay(NewRay, game.Workspace.TargetFilter)
	return Target

Also, another thing that might be an issue is that the player’s character might be in the way of the ray resulting in that being returned by FindPartOnRay. Try using something like FindPartOnRayWithIgnoreList and pass your target filter and the character as a table. (

Does this method work with PC users aswell (assuming i changed the cursor icon & repositioned it in the centre of the screen)

It creates a ray originating from the camera’s position into the camera’s direction, offset by the worldspace position of the x/y coords passed in. (In this case the screen’s center.)

So if you want it to always originate from the center of the screen, this will work on any device.

I am testing it again on Console and same problem again, The player follows camera on PC but not console except this time, no item is being found it constantly prints nil unless i pass through a non-can collide object.

is there another way i can set the depth of the ray except for this method
local NewRay = camera:ScreenPointToRay(viewportSize.X / 2, viewportSize.Y / 2, 300)
by adding 300 in the third arguement? Because i believe that’s where the problem for grabbing is at.

Ah wait, I misread the documentation, the 3rd number is the depth from the camera not the length of the ray. Remove the 3rd argument, as it returns a unit ray. Also it’s better to use ViewportPointToRay since it ignores GUI inset from things like the top bar.

local unitRay = camera:ViewportPointToRay(viewportSize.X / 2, viewportSize.Y / 2)
local ray =, unitRay.Direction * 300)

One thing I don’t get is why the first method we used didn’t work anyways, shift lock shouldn’t affect it in a problematic way afaik. This method shouldn’t have to be necessary. If it still doesn’t work we might be looking at a different problem all together. Might want to use the “FindPartOnRayWithIgnoreList” method instead as it might be that the character still obstructs the ray.