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

How to find the position that mouse is pointing at?

Asked by
sheepposu 561 Moderation Voter
4 years ago

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

Log in to vote
2
Answered by 4 years ago

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

Ad

Answer this question