Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- --
- --
- local function ResizeSystem (frame, mouse, options)
- if (not options) then
- options = {
- MAX_WIDTH = 500,
- MIN_WIDTH = 50,
- MAX_HEIGHT = 100,
- MIN_HEIGHT = 50,
- ENABLED_DIRECTIONS = {
- UP = true,
- RIGHT = true
- }
- };
- end;
- if (not mouse) then
- mouse = game:service 'Players'.localPlayer:GetMouse();
- end;
- options.MouseIconState = false;
- options.MouseButton1Down = false;
- options.MouseIconPrevious = mouse.Icon;
- options.ResizeBindable = Instance.new 'BindableEvent';
- options.MouseBindable = Instance.new 'BindableEvent';
- options.OnInputBegan = game:service 'UserInputService'.InputBegan:connect (function (obj)
- if (obj and obj.UserInputType == Enum.UserInputType.MouseButton1) then
- options.MouseButton1Down = true;
- options.MouseBindable:Fire (true);
- end;
- end);
- options.OnInputEnded = game:service 'UserInputService'.InputEnded:connect (function (obj)
- if (obj and obj.UserInputType == Enum.UserInputType.MouseButton1) then
- options.MouseButton1Down = false;
- options.MouseBindable:Fire (false);
- end;
- end);
- coroutine.wrap (function()
- while true do
- local mouseX, mouseY = mouse.X, mouse.Y;
- local screenX, screenY = mouse.ViewSizeX, mouse.ViewSizeY;
- local framePosX, framePosY = frame.AbsolutePosition.X, frame.AbsolutePosition.Y;
- local frameSizeX, frameSizeY = frame.AbsoluteSize.X, frame.AbsoluteSize.Y;
- local frameXOffset1, frameXOffset2 = framePosX, screenX - (framePosX + frameSizeX);
- local frameYOffset1, frameYOffset2 = framePosY, screenY - (framePosY + frameSizeY);
- local isInResizeY = (mouseX > framePosX and mouseX < (framePosX + frameSizeX) and --Y1 Resizing
- (mouseY > (framePosY - 5) and (mouseY < (framePosY + 5))));
- local isInResizeX = (mouseX > (framePosX + frameSizeX - 5) and mouseX < (framePosX + frameSizeX + 5) and --X2 Resizing
- (mouseY > framePosY and mouseY < (framePosY + frameSizeY)));
- local isInResizeXY = (mouseX > (framePosX + frameSizeX - 5) and mouseX < (framePosX + frameSizeX + 5) and
- (mouseY > (framePosY - 5) and mouseY < (framePosY + 5)));
- if (isInResizeY) then
- options.MouseIconState = true;
- options.MouseIconPrevious = mouse.Icon;
- mouse.Icon = 'rbxassetid://1195128791';
- while (options.MouseButton1Down) do
- local mouseX, mouseY = mouse.X, math.max (math.min (mouse.Y, framePosY + frameSizeY - options.MAX_HEIGHT), options.MAX_HEIGHT);
- local resizeY = (framePosY + frameSizeY) - mouseY;
- frame.Size = UDim2.new (
- 0, frameSizeX,
- 0, resizeY
- );
- frame.Position = UDim2.new (
- 0, framePosX,
- 0, framePosY + (frameSizeY - frame.AbsoluteSize.Y)
- );
- options.ResizeBindable:Fire();
- wait (0);
- end;
- elseif (isInResizeX) then
- options.MouseIconState = true;
- options.MouseIconPrevious = mouse.Icon;
- mouse.Icon = 'rbxassetid://1243635772';
- while (options.MouseButton1Down) do
- local mouseX, mouseY = mouse.X, mouse.Y;
- local resizeX = mouseX - (frameSizeX + frameXOffset1) + frameSizeX;
- resizeX = math.min (math.max (resizeX, options.MIN_WIDTH), options.MAX_WIDTH);
- frame.Size = UDim2.new (
- 0, resizeX,
- 0, frame.AbsoluteSize.Y
- );
- options.ResizeBindable:Fire();
- wait (0);
- end;
- else
- if (options.MouseIconState) then
- options.MouseIconState = false;
- mouse.Icon = options.MouseIconPrevious;
- end;
- end;
- game:service 'RunService'.RenderStepped:wait();
- end;
- end)();
- return options;
- end;
- users = game:service 'Players';
- user = users.localPlayer;
- gui = user.PlayerGui;
- mouse = user:getMouse ();
- create = LoadLibrary 'RbxUtility'.Create;
- runService = game:service 'RunService';
- userInputService = game:service 'UserInputService';
- frame = create 'Frame' {
- Size = UDim2.new (0, 100, 0, 100),
- Position = UDim2.new (0.5, -50, 0.5, -50),
- Parent = create 'ScreenGui' { Parent = gui },
- create 'TextLabel' {
- Size = UDim2.new (1, 0, 0, 30),
- Text = 'AAAAAAA'
- }
- };
- local function oc (f)
- local w, d = nil, false;
- w = function (...)
- if (d) then return end;
- local ret = { ypcall (f, ...) };
- if (table.remove (ret, 1)) then
- return unpack (ret);
- else
- d = true;
- error (ret [2], 2);
- end;
- end;
- return w;
- end;
- local function connectEvent (c, f, ...)
- if (... ~= nil) then
- c:connect (f);
- else
- while true do
- f (c:wait (...));
- end;
- end;
- end;
- connectEvent (userInputService.InputBegan, function (c)
- if (c and c.UserInputType == Enum.UserInputType.MouseButton1) then
- mouse1Down = true;
- end;
- end, 1);
- connectEvent (userInputService.InputEnded, function (c)
- if (c and c.UserInputType == Enum.UserInputType.MouseButton1) then
- mouse1Down = false;
- end;
- end, 1);
- connectEvent (runService.RenderStepped, function()
- local mouseX, mouseY = mouse.X, mouse.Y;
- local screenX, screenY = mouse.ViewSizeX, mouse.ViewSizeY;
- local framePosX, framePosY = frame.AbsolutePosition.X, frame.AbsolutePosition.Y;
- local frameSizeX, frameSizeY = frame.AbsoluteSize.X, frame.AbsoluteSize.Y;
- --XOffset <---X1---><frame><---X2--->
- --YOffset ^---Y1---v^framev^---Y2---v
- --OFFSETS ^
- -- Y1
- -- v
- -- < X1 >FRAME< X2 >
- -- ^
- -- Y2
- -- v
- local frameXOffset1, frameXOffset2 = framePosX, screenX - (framePosX + frameSizeX);
- local frameYOffset1, frameYOffset2 = framePosY, screenY - (framePosY + frameSizeY);
- local isInResizeY = (mouseX > framePosX and mouseX < (framePosX + frameSizeX) and --Y1 Resizing
- (mouseY > (framePosY - 5) and (mouseY < (framePosY + 5))));
- local isInResizeX = (mouseX > (framePosX + frameSizeX - 5) and mouseX < (framePosX + frameSizeX + 5) and --X2 Resizing
- (mouseY > framePosY and mouseY < (framePosY + frameSizeY)));
- local isInResizeXY = (mouseX > (framePosX + frameSizeX - 5) and mouseX < (framePosX + frameSizeX + 5) and
- (mouseY > (framePosY - 5) and mouseY < (framePosY + 5)));
- if (isInResizeY) then
- mouse.Icon = 'rbxassetid://1195128791';
- while (mouse1Down) do
- local mouseX, mouseY = mouse.X, math.max (math.min (mouse.Y, framePosY + frameSizeY - 50), 100);
- local resizeY = (framePosY + frameSizeY) - mouseY;
- frame.Size = UDim2.new (
- 0, frameSizeX,
- 0, resizeY
- );
- frame.Position = UDim2.new (
- 0, framePosX,
- 0, framePosY + (frameSizeY - frame.AbsoluteSize.Y)
- )
- wait (0);
- end;
- elseif (isInResizeX) then
- mouse.Icon = 'rbxassetid://1243635772';
- while (mouse1Down) do
- local mouseX, mouseY = mouse.X, mouse.Y;
- local resizeX = mouseX - (frameSizeX + frameXOffset1) + frameSizeX;
- resizeX = math.min (math.max (resizeX, 50), 500);
- frame.Size = UDim2.new (
- 0, resizeX,
- 0, frame.AbsoluteSize.Y
- );
- wait (0);
- end;
- else
- mouse.Icon = "";
- end;
- end);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement