Attempting to scale a part from a specific corner? [UPDATE]
Asked by
6 years ago Edited 6 years ago
I am trying to make a selection box when you drag your mouse. Like you do on your desktop to select multiple icons.
I have the basics of the code down but my problem is when I drag in any other quadrant than the 4th I the part doesnt position correctly. By quadrant I mean, think of a graph and the bottom right square is quadrant 4.
Heres my code so far.
01 | local SelectionStartPosition |
02 | local SelectionEndPosition |
04 | function SelectionBegan() |
05 | SelectionStartPosition = Mouse.Hit.Position |
08 | function SelectionEnded() |
09 | SelectionEndPosition = Mouse.Hit.Position |
11 | local SelectionPart = Instance.new( "Part" ) |
12 | SelectionPart.Size = Vector 3. new(math.abs(SelectionStartPosition.X - SelectionEndPosition.X), math.abs(SelectionStartPosition.Y - SelectionEndPosition.Y), math.abs(SelectionStartPosition.Z - SelectionEndPosition.Z)) |
13 | SelectionPart.Position = SelectionStartPosition - Vector 3. new(SelectionPart.Size.X/ 2 , 0 , SelectionPart.Size.Z/ 2 ) |
14 | SelectionPart.Anchored = true |
15 | SelectionPart.Parent = workspace |
18 | Mouse.Button 1 Down:Connect(SelectionBegan) |
19 | Mouse.Button 1 Up:Connect(SelectionEnded) |
Thank you for your time :)
Heres an image of a chart just in case your curious.
http://aventalearning.com/content168staging/2006AlgebraIA/images/u4_s1_3.gif
Also heres a gif of the top bottom thing I was talking about.
https://gyazo.com/2289dd3041144fd777db401f6939d944
[UPDATE]
I have managed to solve the scaling problem, by converting the scale numbers into positive numbers that seems to work :) Now I am trying to solve the positioning problem.