Rvzol
(Aiden)
April 29, 2024, 12:13am
#1
Basically, I need to get the LookVector of a mouse. But I’m not really sure how to do this??
This is what I was trying to use
local MouseDirection = mouse;UnitRay.Direction
I get this error: UnitRay is not a valid member of Vector3
How am I supposed to get the LookVector of a Mouse?
Den_vers
(Den_vers)
April 29, 2024, 12:17am
#2
Use this code:
local lookVector = (mouse.Hit.Position - camera.CFrame.Position).Unit
Tell me your results (the lookvector will have a magnitude of 1).
Rvzol
(Aiden)
April 29, 2024, 12:41am
#4
it says "Hit is not a valid member of Vector3 "
Den_vers
(Den_vers)
April 29, 2024, 12:43am
#5
Is mouse
a Mouse
object or a position?
Rvzol
(Aiden)
April 29, 2024, 12:51am
#6
Well I have a local script that fires the current mouse and camera,
event:FireServer(m.Hit.Position,chr,camera)
then there is a server script the gets the lookvector of the mouse.
local LookVector = (m.Hit.Position - camera.CFrame.Position).Unit -- Error: "Hit is not a valid member of Vector3"
If I just use
event:FireServer(m,chr,camera) -- local script
then it gets the error Attempt to index nil with ‘Hit’ on the ServerScript
Den_vers
(Den_vers)
April 29, 2024, 12:54am
#7
You’re firing the position of the mouse, and then retrieving it like it’s a mouse. You can’t send that object to the server, because it doesn’t exist on the server. Instead keep the original client code, and switch the server code to this:
local LookVector = (m - camera.CFrame.Position).Unit
1 Like
system
(system)
Closed
May 13, 2024, 12:54am
#8
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.