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)
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”
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)