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

How do I get the vector3 of a mouse?

Asked by 6 years ago

I have this small portion of my code: bulletis a part that is inserted in the workspace.

local BV = Instance.new("BodyVelocity",bullet)
        BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
        --BV.Velocity = script.Parent.Handle.CFrame.lookVector*100
        BV.Velocity = mouse.Hit

Everytime I run this code there's an error saying: bad argument #2 to '?' (Vector3 expected, got number) How do I get the vector 3 of a mouse?

Thanks!

2 answers

Log in to vote
-1
Answered by 6 years ago

Position isn't a member of Mouse But there's another thing called p which is a property of hit which is also a property of the mouse Knowing that We can get the position of the mouse in a Vector3 easily

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

while wait() do
    print(mouse.hit.p) --This will print the Vector3 position of the mouse
end
0
Thank you. I forgot about that! wilsonsilva007 373 — 6y
0
The retard who downvoted my answer is gay >:C BerrySus 65 — 6y
Ad
Log in to vote
-2
Answered by
GingeyLol 338 Moderation Voter
6 years ago
Edited 6 years ago
--local part = game.Workspace:FindFirstChild("Part")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

print(mouse.CFrame)
print(mouse.Position)
--part.CFrame = mouse.CFrame
0
Error:Position is not a valid member of mouse. wilsonsilva007 373 — 6y
0
lol BerrySus 65 — 6y

Answer this question