Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

3 comments

1

Oh thanks, I didnt realize that. The name "target" is kind of misleading, lol.

0

Target isn't the string name of the object the mouse is resting on, print just defaults to it to name object values.

This discussion is preserved as it was. New answers, comments, and votes are closed.