How to get the mouse position?

I would like to get the mouse position and achieve something like this:

if mousePosition == (5,5,5) then
   -- do something
elseif mousePosition < (5,5,5) then
   -- do something
else
   -- do something
end

How can I do something like that? :confused:

1 Like

You might want to look at this entry on the developer wiki:
https://developer.roblox.com/en-us/api-reference/property/Mouse/Hit

2 Likes

what do u exactly want?

The 2 dimensional position or the 3 dimensional ?

please be more sepcific :grinning_face_with_smiling_eyes:

1 Like
local player = game.Players.LocalPlayer
local mouse = player.Mouse
local mousePos = player.Hit.p
print(mousePos)
if mousePos == Vector3.new(5, 5, 5) then
	--do something
elseif mousePos.X < 5 and mousePos.Y < 5 and mousePos.Z < 5 then
	-- do something
else
	-- do something
end

I believe this is the exact logic you’re looking for.