For a while now I have had this problem where studio crashes because of horrible scripting (but I’ve been too lazy to try and figure it out). Basically I have a frame that you can drag to resize, and a size limiter. But due to the size limiter being in another script and being scripted poorly, it crashes studio.
I really just want to integrate the size limiter into the resize script (as the title says) so studio doesn’t crash. I have tried a few things including adding a debounce to the size limiter, but that just broke everything. The scripts are below.
Drag to resize script
Script
Size limiter script
Script
So that is basically it. Any pointers on how to do this would be great, thank you!
i really recommend you to recreate your entire script and learn about TweenService, but here is the solution to the size limiter script:
local cam = workspace.Camera
local viewportSize = cam.ViewportSize
local MinSizeX = 484 --378
local MinSizeY = 347--271
--local MaxSizeX = 968
--local MaxSizeY = 694
local function ScaleToOffsetX(x)
x *= viewportSize.X
return x
end
local function ScaleToOffsetY(y)
y *= viewportSize.Y
return y
end
local MaxSizeX = ScaleToOffsetX(1)
local MaxSizeY = ScaleToOffsetY(1)
local ObjectSize = script.Parent
ObjectSize:GetPropertyChangedSignal("Size"):Connect(function()
if ObjectSize.Size.X.Offset < MinSizeX then
ObjectSize.Size = UDim2.new(ObjectSize.Size.X.Scale, MinSizeX, ObjectSize.Size.Y.Scale, ObjectSize.Size.Y.Offset)
end
if ObjectSize.Size.Y.Offset < MinSizeY then
ObjectSize.Size = UDim2.new(ObjectSize.Size.X.Scale, ObjectSize.Size.X.Offset, ObjectSize.Size.Y.Scale, MinSizeY)
end
if ObjectSize.Size.X.Offset > MaxSizeX then
ObjectSize.Size = UDim2.new(ObjectSize.Size.X.Scale, MaxSizeX, ObjectSize.Size.Y.Scale, ObjectSize.Size.Y.Offset)
end
if ObjectSize.Size.Y.Offset > MaxSizeY then
ObjectSize.Size = UDim2.new(ObjectSize.Size.X.Scale, ObjectSize.Size.X.Offset, ObjectSize.Size.Y.Scale, MaxSizeY)
end
end)
i recommend you to search to understand, because it can make so much cool things, like go from 1 to 10 in how many seconds do you want and with the interpolation that you want