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

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

Asked by
ipiano 120
10 years ago

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

Log in to vote
1
Answered by 10 years ago

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.

0
I would prefer Mouse.Hit also, but I can't find away to get it ServerSide with FilteringEnabled :P ipiano 120 — 10y
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 Spongocardo 1991 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

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

Answer this question