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

How can i place a part based on where the mouse is ?

How can i place a part based on where the mouse is ? I want the player to place parts in the game world based on where the mouse is ? but how do i do that ? I wanted to have some script to show but i have no idea where to start :/

1 answer

✓ Accepted answer

mouse.Hit is the CFrame of where the mouse is pointing

mouse.Hit.p is just mouse.Hit but in a Vector3

mouse = game.Players.LocalPlayer:GetMouse() -- this will get the mouse, and has to be localscript

mouse.Button1Down:connect(function() -- button1down fires when the left mouse button is put into a down state
	local part = Instance.new("Part" , workspace) --makes the part
	part.Position = mouse.Hit.p -- and here is the mouse coming in
end)


for more stuff on the mouse, go to the wiki page for mouse

2 comments

0

thanks so much, i did a script just like that but did it in a Script not a LocalScript.

0

oh, well when using game.PLayers.LocalPlayer, you need a local script, and when using the mouse.

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