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

Help with Mouse?

Asked by 10 years ago

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

Log in to vote
0
Answered by
ZeroBits 142
10 years ago

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.

Ad

Answer this question