It’s kind of irritating that the UserInputService doesn’t have a way to give 3D position. MouseMovement > Position returns the pixel-based screen coordinates (as a Vector3:
[X, Y, 0]).
The script, which runs locally, uses that 2D coordinate to get the mouse’s position via the Camera’s
ScreenPointToRay method. If you have something else that works feel free to post it.
local Players = game:GetService("Players") local Camera = workspace.CurrentCamera function GetMousePoint(X, Y) local RayMag1 = Camera:ScreenPointToRay(X, Y) --Hence the var name, the magnitude of this is 1. local NewRay = Ray.new(RayMag1.Origin, RayMag1.Direction * 1000) local Target, Position = workspace:FindPartOnRay(NewRay, Players.LocalPlayer.Character) return Position end --Listen to UserInputService's "InputChanged" event, and get the --Position property of the InputObject, which will be a Vector3. Pass X and Y into the --function. It will return a position in the 3D world.