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.
local SelectionStartPosition local SelectionEndPosition function SelectionBegan() SelectionStartPosition = Mouse.Hit.Position end function SelectionEnded() SelectionEndPosition = Mouse.Hit.Position local SelectionPart = Instance.new("Part") SelectionPart.Size = Vector3.new(math.abs(SelectionStartPosition.X - SelectionEndPosition.X), math.abs(SelectionStartPosition.Y - SelectionEndPosition.Y), math.abs(SelectionStartPosition.Z - SelectionEndPosition.Z)) SelectionPart.Position = SelectionStartPosition - Vector3.new(SelectionPart.Size.X/2, 0, SelectionPart.Size.Z/2) SelectionPart.Anchored = true SelectionPart.Parent = workspace end Mouse.Button1Down:Connect(SelectionBegan) Mouse.Button1Up: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.
A simple way to do this is by using the Anchor Point property. So, for instance,
local guiObj = script.Parent guiObj.AnchorPoint = Vector3.new(0.5,0.5) while wait() do guiObj .Size = guiObj .Size + UDim2.new(0,1,0,1) end
The code above with make the gui object expand from the center
So, if you wanted to expand the gui object from the top right you would do this:
local guiObj = script.Parent guiObj.AnchorPoint = Vector3.new(1,0) while wait() do guiObj .Size = guiObj .Size + UDim2.new(0,1,0,1) end
Hope this helped!