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

What's the difference between Mouse.Hit and Humanoid.TargetPoint?

I've been working a bit with RemoteEvents, and I noticed that there doesn't seem to be a way to send the CFrame value from Mouse.Hit in a LocalScript to a Server script via a RemoteEvent. (If this IS possible, please enlighten me!)

So I looked into how the Roblox Weapons work, and noticed that they don't use Mouse.Hit, they use Humanoid.TargetPoint (The Humanoid object in the character, that is).

Besides the fact that one is a CFrame and one is a Vector3Value, what's the difference; why doesn't everyone just use Humanoid.TargetPoint?

Thanks for any light that can be shed on the issue!

2 answers

✓ Accepted answer

The TargetPoint property is a property which shows where the Humanoid is trying to walk to and using in that in... let's say a rocket launcher script, the rocket would fire where the humanoid is walking to.

The Hit property is different to the TargetPoint property because it shows where the mouse is pointing to in the 3D world. Using that in said rocket launcher script would make the rocket fly where the mouse is pointing. Sometimes the position may not be available because the mouse could be pointing at nothing, like pointing it at the sky.

Using TargetPoint or Hit is just personal preference, I prefer to use the Hit property while others may prefer to use TargetPoint.

2 comments

0

I would prefer Mouse.Hit also, but I can't find away to get it ServerSide with FilteringEnabled :P

0

Try using a RemoteFunction that makes a call from the server to the client, where the function would return the CFrame value of mouse.Hit. Also, you can return the Vector3 value of mouse.Hit by doing mouse.Hit.p. http://wiki.roblox.com/index.php?title=RemoteFunction_and_RemoteEvent_Tutorial#Invoke_Client

You can always use mouse.Hit.p to convert that CFrame into a Vector3 if you need to.

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