We use cookies on this site to enhance your user experience

Add Handles for Resizable GUI

Add Handles for Resizable GUI

Jun 23 2018, 2:02 AM PST


You want to use the Handles to create a resize GUI.


Create the GUI setup in the StarterGui and then in a LocalScript use MouseDrag on the Handles object.

local handles, origin = script.Parent, 0
handles.Adornee = game.Workspace.Part
handles.MouseDrag:connect(function(norm, dist)
	handles.Adornee:Resize(norm, math.floor(dist - origin / handles.Adornee.ResizeIncrement + .5) * handles.Adornee.ResizeIncrement)
	origin = dist
	origin = 0 


Since we’re using events with the Handles object we’re going to have to create the GUI itself in studio. Therefore create a ScreenGui like normal inside of the StarterGui. However notice that you cannot create the Handles object inside of the ScreenGui. In order to remedy this click the Workspace and then insert the Handles object. Then right click the object and choose “Cut”. Then right click the ScreenGui you created and click “Paste Into”. Then put a LocalScript into the Handles to get started.

We set the Handles Adornee to be a part in the Workspace. Then we connect the Handles MouseDrag event. This event fires when the handles GUI has been dragged. We use the parameters given to the GUI in order to re-size the part accordingly. Basically we call the Resize method on the Adornee of the Handles (which in this case is game.Workspace.Part). Then we pass Resize norm (this identities the side that is to be resized) and we do some math with the amount dragged and the point we started from. Then we also connect the MouseButton1Down event (which is what is fired before MouseDragged is fired). With this we just reset the “origin” variable.

  • gui