Getting Player Mouse Position

Context:

I need to track the players mouse, preferably seperately on the X and Y axis to get the real time data which i’ll use to make changes to objects in the workspace.

How do I do this?

I understand it will probably involve UserInputService, but i’m not educated in what area to use.
Any help is appreciated, how would I go about doing this?

1 Like

Really you would only require Player and the ROBLOX GetMouse() function, you could do like

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()


local function playerMouse(x, y)
-- this work here is for you
end)

You can read up on this here Player | Roblox Creator Documentation

Alright, makes sense. How would I use this function in a practical environment? do I need to input the x,y arguments myself or are they pre defined. I’m looking to move a part in workspace based on the Y axis value if that context is of any use.

To gie a bit more detail on what @LiegePalpatine mentioned, it must be in a localscript since LocalPlayer, and for your use, I think the Move event if what you require. The Mouse Object also contains 2 properties for the x and y coordinates which are .X and .Y

The documentation should have all that you require

1 Like

Up to you but I believe you should input them yourself, also if you want there is another method to dragging parts in these documentations