How to get mouse position of UserInputType.MouseButton1?

I’m writing a code that uses elseif Input.UserInputType == Enum.UserInputType.MouseButton1 then to get the player’s mouse input, how do I get the player’s cursor position using this?

You can use this function: UserInputService | Roblox Creator Documentation.

Also make sure to take into account of gui inset by using GUIService like in this mouse to 3d space function here:

1 Like

Input.Position will give you a Vector3 value where the X & Y components refer to the position of the mouse in 2D space (on your screen). Add 36 to the Y-component to account for the TopBar inset.

Below is tested output
devforum reply

You could also retrieve a player’s mouse location with Player:GetMouse()