I'm going to throw out an answer because I think I'm okay at using the mouse.
First off, you can only do this in a Local Script. I think you already know this but it's important to get this established.
Second, there are lots of things that your question could mean, so I'm going to go through most of the mouse properties.
Mouse.Hit
Mouse.Hit is a CFrame value of the exact point the mouse is targeting in the 3d world. This is used for a ton of things. You would get the mouse.Hit similar to so,
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
mouse.Hit
Normally it would be best to hook this up to a loop or a mouse move event.
Mouse.Hit.p
This is like mouse.Hit, but instead of being a CFrame, it's a Vector3. To be exact, it's a Vector3 of the mouses position only. You would get this in about the same way as with the Mouse.Hit but with a p at the end.
Mouse.X, Mouse.Y
There is no mouse.Z, because this isn't a value from a Vector3 or something. This is the position of the Mouse on the screen. Because the screen is a two denominational object, there's only two coordinates. This is often used with GUIs and sometimes part rotation.
More info about mouse.X, mouse.Y.
I'm going more into this because I think this is what you want. To be exact, mouse.X will return the number of pixels the mouse is away from left side of the screen. mouse.Y returns the number of pixels the mouse is from the top of the screen.
You would get mouse.X and mouse.Y like this,
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local x = mouse.X
local y = mouse.Y
However, if you wanted to keep track of this using a print statement then you could do something like this,
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
mouse.Move:connect(function()
local x = mouse.X
local y = mouse.Y
print(x,y)
end)
Hope I Helped a Little
Good Luck!
1 comment
mouse.X and mouse.Y are the on screen coords. And mouse.Hit is the CFrame of what the mouse is hitting in the workspace