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

Help with Mouse?

I was making a building tool, and then I stumbled upon a problem the Display part follows the camera due to Mouse.Origin,I want the part to follow the mouse on another part's surface(kinda like the Stamper tool).How Would I do that? Please explain if you manged to find out how.

Player = game.Players.LocalPlayer
Tool = script.Parent
Mouse = Player:GetMouse()
Displayed = true
----------------------------------
	Tool.Equipped:connect(function(_)
		DisplayPart = Instance.new("Part",Workspace)
			DisplayPart.Anchored = true
			DisplayPart.Transparency = 0.5
			DisplayPart.CanCollide = false
				while Displayed do
					wait(0.1)
					MousePosition = Mouse.Origin
					DisplayPart.CFrame = CFrame.new(MousePosition.X,MousePosition.Y,MousePosition.Z)
				end
					
------------------------------------
		LeftClick = Mouse.Button1Down:connect(function(_)
				local Part = Instance.new("Part",Workspace)
					Hit = Mouse.Hit
						Part.Position = Vector3.new(Hit.X,Hit.Y,Hit.Z)
-------------------------------------					
		Tool.Unequipped:connect(function(_)
			LeftClick:disconnect()
				end)
			end)
		end)

1 answer

Mouse.Origin should be Mouse.Hit, Mouse.Hit isn't where You clicked, it's the Mouse's location in 3d space, at any time.

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