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

How do I get the vector3 of a mouse?

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

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

2 comments

0

Thank you. I forgot about that!

0

The retard who downvoted my answer is gay >:C

--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

2 comments

0

Error:Position is not a valid member of mouse.

0

lol

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