Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-2

How do I get the Mouse Position on a block?

Asked by 10 years ago

Like how do I get the mouses position on a block for say not on the screen but in real space? I have no clue how to go about doing this so I was hoping I could get some help. Also how would I move the arms to a different position on the body say move them back while still keeping them jointed?

0
mouse.Hit is the CFrame of where the mouse is on in 3D space. Tkdriverx 514 — 10y
0
Isnt that for clicked? User#600 0 — 10y
0
Ya, im looking for something that will run without clicking User#600 0 — 10y
0
I tried using it and it printed 0,0,0 User#600 0 — 10y

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

Mouse and PlayerMouse objects have a Hit property which is a CFrame. The rotation doesn't mean anything.

This is the position where the mouse is hovering.

Mouse objects can be obtained usin the (GetMouse)[http://wiki.roblox.com/index.php?title=API:Class/Player/GetMouse] method on a LocalPlayer (from a LocalScript only) or from the events Equipped or Selected of the respective Tool and Hopperbin objects.

Mouse objects, while active, get their values (like Hit and Target) updated constantly, not just the moment the event occurs.

Consequently using either the MouseMoved event of the mouse or a simple while loop can track the motion of the arm.

Note that MouseMoved only fires when the mouse itself moves across the screen, and so the object the mouse is pointing at may move and not fire the event.

Ad

Answer this question