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

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

Asked by 8 years ago

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

Log in to vote
1
Answered by
theCJarmy7 1293 Moderation Voter
8 years ago

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

0
thanks so much, i did a script just like that but did it in a Script not a LocalScript. HyperSpeed05 40 — 8y
0
oh, well when using game.PLayers.LocalPlayer, you need a local script, and when using the mouse. theCJarmy7 1293 — 8y
Ad

Answer this question