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

How to make a model to move to mouse position using while loop?

Asked by 6 years ago

The code below is when the mouse is clicked it will clone that part at the mouses position. But I need help to make a X,Y,Z for a while loop that moves the part to the mouses position, specifically, how to make a Z axis for the Model.

    local Part =game.Workspace.Model
    playerMouse = game.Players.LocalPlayer:GetMouse()
    playerMouse.Button1Down:connect(function(Hit)
        local Part2 = Part:Clone()
        Part2.Parent = game.Workspace
        Part2:MakeJoints()
        local x = playerMouse.Hit.X
        local y = playerMouse.Hit.Y
        local z = playerMouse.Hit.Z
        Part:MoveTo(Vector3.new(x,y,z))
    end)

Answer this question