Help with ingame gui resizer

Trying to make the gui resizer but can’t figure out how to stop the teleporting

I’ve tried subtracting the old position with the new position

-- ignore anything to do with oldPos
local draggableObject = require(game.ReplicatedStorage.DraggableObject)

local drag = draggableObject.new(script.Parent)
drag:Enable()

local oldPos = script.Parent.Parent.Console.Position

script.Parent:GetPropertyChangedSignal("Position"):Connect(function()
	if drag.Dragging then
		script.Parent.Parent.Console.Position = script.Parent.Position
		script.Parent.Parent.Console.Size = UDim2.new(
			script.Parent.Parent.Console.Size.X.Scale,
			script.Parent.Position.X.Offset,
			script.Parent.Parent.Console.Size.Y.Scale,
			script.Parent.Position.Y.Offset
		)
		
	end
end)

script.Parent.Parent.Console:GetPropertyChangedSignal("Position"):Connect(function()
	if not drag.Dragging then
		script.Parent.Position = script.Parent.Parent.Console.Position
		oldPos = script.Parent.Parent.Console.Position
	end
end)

I’m also using this module (Simple Module For Creating Draggable GUI Elements) that i modified to let me drag other guis using another one (so there’s an invisible topbar that lets me drag the console)

Here’s the model:
https://create.roblox.com/marketplace/asset/15025236417/ConsoleHelp

1 Like

You probably need to remove this line (line 11 in the provided code snippet).

I forgot to mention that the anchor point is 1,1

I also just updated the original post to have the model
(https://create.roblox.com/marketplace/asset/15025236417/ConsoleHelp)

I would suggest finding a way to save the position of console after moving it and applying it after the resize is performed. Could save it to a “StringValue”

I fixed it.
New code is:

local draggableObject = require(game.ReplicatedStorage.DraggableObject)

local drag = draggableObject.new(script.Parent)
drag:Enable()

local oldPos = script.Parent.Parent.Console.Position
local oldSiz = script.Parent.Parent.Console.Size
local wowie = oldSiz-oldPos

script.Parent:GetPropertyChangedSignal("Position"):Connect(function()
	if drag.Dragging then
		script.Parent.Parent.Console.Position = script.Parent.Position
		script.Parent.Parent.Console.Size = UDim2.new(
			script.Parent.Parent.Console.Size.X.Scale,
			script.Parent.Position.X.Offset+wowie.X.Offset,
			script.Parent.Parent.Console.Size.Y.Scale,
			script.Parent.Position.Y.Offset+wowie.Y.Offset
		)
		
	end
end)

script.Parent.Parent.Console:GetPropertyChangedSignal("Position"):Connect(function()
	if not drag.Dragging then
		script.Parent.Position = script.Parent.Parent.Console.Position
		oldPos = script.Parent.Parent.Console.Position
		oldSiz = script.Parent.Parent.Console.Size
		wowie = oldSiz-oldPos
	end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.