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

Why does my resize part depending on position of mouse script not work?

Asked by 6 years ago

The code below is supposed to 'resize' a part depending on the distance between the mouse and the part. It glitches out and does some sort of a random spasm when the mouse moves, but overall works. How do I fix this?

    Mouse.Button1Down:Connect(function()
        PlaceFirstPoint:Disconnect()
        Mouse.Move:Connect(function()
            OriginalMagnitude = (Mouse.Hit.p - GhostWall.Part.Position).magnitude
            print("Original: "..OriginalMagnitude)
            if OriginalMagnitude > (GhostWall.Part.Size).magnitude then
                GhostWall.Part:Resize(2, MathsLibrary.RoundAToB((GhostWall.Part.Position - Mouse.Hit.p).magnitude, I))
            else
                GhostWall.Part:Resize(2, MathsLibrary.RoundAToB(-(GhostWall.Part.Position - Mouse.Hit.p).magnitude, I))
            end
            NewMagnitude = (Mouse.Hit.p - GhostWall.Part.Position).magnitude
            print("New: "..NewMagnitude)
        end)
    end)

Answer this question