~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
Player = game.Players.LocalPlayer mouse = Player:GetMouse() n = script.Parent function mold() x = Instance.new("Part", game.Workspace) x.Name = "Crystal" x.Anchored = true x.Size = Vector3.new(5, 5, 5) x.Friction = 0.4 x.Shape = "Block" x.CFrame = CFrame.new(x.Position,mouse.Hit.p) end n.Activated:connect(mold)
This is a localscript which is inside a tool.I want to make a part spawn where the mouse is.Can anyone help me?
-mouse.Hit.p is a Vector3 value. use x.Position instead of x.CFrame. -Consider changing x to local x. -Parts are blocks by default, no need to specify that. -"game.Workspace" can be shortened to "workspace", in case you're feeling lazy. -If you're making a tool (and not a HopperBin), you must have a part in the tool called "Handle".
Player = game.Players.LocalPlayer mouse = Player:GetMouse() n = script.Parent function mold() local x = Instance.new("Part", workspace) x.Name = "Crystal" x.Anchored = true x.Size = Vector3.new(5, 5, 5) x.Friction = 0.4 x.Position = mouse.Hit.p end n.Activated:connect(mold)
If you truly do not want your tool to have a handle, put this script in a HopperBin, and place the HopperBin in the StarterPack.
Player = game.Players.LocalPlayer n = script.Parent function onButton1Down(mouse) local x = Instance.new("Part", workspace) x.Name = "Crystal" x.Anchored = true x.Size = Vector3.new(5, 5, 5) x.Friction = 0.4 x.Position = mouse.Hit.p end function onSelected(mouse) mouse.Button1Down:connect(function() onButton1Down(mouse) end) end n.Selected:connect(onSelected)