Problem with interaction system

Hi everyone! I was working on a game and I wanted to make an interaction system. There’s no issue for PC players but there’s a problem for Mobile players. As you see in the video, visuality not works how I want. For the Mobile/Console players, I’m getting the middle of the screen to check the distance between the interaction item and Mouse/Target/Point.

if Player:GetAttribute("Device") == "Mobile" or Player:GetAttribute("Device") == "Console" then
	local VectorPoint = Vector2.new(InteractionUI.AbsoluteSize.X/2, InteractionUI.AbsoluteSize.Y/2) --to get middle of the screen
	local ray = Camera:ViewportPointToRay(VectorPoint.X, VectorPoint.Y, 0) --raycasting

	local raycastResult = workspace:Raycast(
		ray.Origin, 
		(ray.Direction)*Settings.RenderRange,
		raycastParams
	)

	if raycastResult then
		MouseDistance = (PrimaryPart.Position - raycastResult.Position).Magnitude
	else
		MouseDistance = 9999
	end
else
	MouseDistance = (PrimaryPart.Position - Mouse.Hit.Position).Magnitude
end

Can you explain your issue more? What is the PC version doing that the mobile version is not? Can you post the code for the PC version?

Sorry for the late reply.

As you can see in the video (13s-18s part of I look baseplate and interact doesn’t show up) raycast result returns ‘nil’ this is why the interact doesn’t show up. It has to show up closer. I want to fix it, is there another way?