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

How do you use Mouse.Target? (Vector3 expected, got Object error)

Asked by 4 years ago

I've been trying to do this code:

local newPosition = Mouse.Target

but I get some error about it being an object and not a Vector3 when I assign it to things like part = newPosition.

Any solutions?

1 answer

Log in to vote
0
Answered by
Psudar 882 Moderation Voter
4 years ago
Edited 4 years ago

Mouse.Target is the object in 3D space the mouse is pointing to.

For example, if the mouse rests on a brick, the target would be the name of the brick.

print(mouse.Target)

Output: Part

If you want to use the position of the mouse, try mouse.Hit.Position.

local newPosition = mouse.Hit.Position
part.Position = newPosition 

Cheers.

1
Oh thanks, I didnt realize that. The name "target" is kind of misleading, lol. ShashMouthDZX 15 — 4y
0
Target isn't the string name of the object the mouse is resting on, print just defaults to it to name object values. InfiniteYield 41 — 4y
Ad

Answer this question