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

How to find the position that mouse is pointing at?

I want to make a game where players can place blocks. In order to do so I have to find the position that the mouse is pointing at. How can I do this? I was reading somewhere that I can do this using rays. Can someone also explain what are rays, and how are they used?

1 answer

✓ Accepted answer

The quickest way to do this would be just doing this in a localscript

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

while true do--showcasing purposes
	print(mouse.Hit.Position)
	wait()
end

mouse.Hit being a CFrame, and mouse.Hit.Position being the position component of that CFrame

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