Increase and Decrease frame

I made a system to configure the frame size, but it’s not working very well, sometimes in the part to decrease it increases and in the part to increase it decreases, what do I do?

Video:
https://gyazo.com/47083f5e9c1aac9d8a874fb80edb1143

Code:

			v.DragContinue:Connect(function()
				local Position = tostring(v.Parent.Position.X.Scale)
				local str = string.format("%.1f", Position)
				v.Parent.Parent.Parent.Number.Text = str
				if v.Parent.Parent.Parent.Name == "TransparencyFrame" then
					if ActualSlot.ClassName == "ImageButton" and ActualSlot.ImageTransparency <0.6 then
						ActualSlot.ImageTransparency = tonumber(str)
					elseif ActualSlot.ClassName == "TextButton" and ActualSlot.TextTransparency <0.6 then
						ActualSlot.TextTransparency = tonumber(str) 
					end
				elseif v.Parent.Parent.Parent.Name == "SizeFrame" then
					if tonumber(str) > PreviousSize and tonumber(str) <0.6 then
						PreviousSize = tonumber(str)
						local SizeX = ActualSlot.Size.X+UDim.new(0.1,0)
						local SizeY = ActualSlot.Size.Y+UDim.new(0.1,0)
						ActualSlot.Size = UDim2.new(SizeX, SizeY)
					elseif tonumber(str) < PreviousSize and tonumber(str) >0.1 then
						PreviousSize = tonumber(str)
						local SizeX = ActualSlot.Size.X-UDim.new(0.2,0)
						local SizeY = ActualSlot.Size.Y-UDim.new(0.2,0)
						ActualSlot.Size = UDim2.new(SizeX, SizeY)						
					end				
				end
			end)
```
3 Likes

Your code has the following errors:

  1. ActualSlot is not defined anywhere in the script. It should be defined before being used.
  2. In the SizeFrame condition, there are issues with the calculations for SizeX and SizeY.
  3. The variable v is not defined either. Make sure to define it before using it.

The correct code is:

local v = script.Parent -- assuming script is a child of the element you want to use

local PreviousSize = 0
local ActualSlot = script.Parent.Parent -- replace with the actual parent element

v.DragContinue:Connect(function()
    local Position = tostring(v.Parent.Position.X.Scale)
    local str = string.format("%.1f", Position)
    v.Parent.Parent.Parent.Number.Text = str

    if v.Parent.Parent.Parent.Name == "TransparencyFrame" then
        if ActualSlot.ClassName == "ImageButton" and ActualSlot.ImageTransparency < 0.6 then
            ActualSlot.ImageTransparency = tonumber(str)
        elseif ActualSlot.ClassName == "TextButton" and ActualSlot.TextTransparency < 0.6 then
            ActualSlot.TextTransparency = tonumber(str)
        end
    elseif v.Parent.Parent.Parent.Name == "SizeFrame" then
        if tonumber(str) > PreviousSize and tonumber(str) < 0.6 then
            PreviousSize = tonumber(str)
            local SizeX = ActualSlot.Size.X.Scale + 0.1
            local SizeY = ActualSlot.Size.Y.Scale + 0.1
            ActualSlot.Size = UDim2.new(SizeX, 0, SizeY, 0)
        elseif tonumber(str) < PreviousSize and tonumber(str) > 0.1 then
            PreviousSize = tonumber(str)
            local SizeX = ActualSlot.Size.X.Scale - 0.2
            local SizeY = ActualSlot.Size.Y.Scale - 0.2
            ActualSlot.Size = UDim2.new(SizeX, 0, SizeY, 0)
        end
    end
end)

I hope this code helps you with your problem.

1 Like

1 - This variable is defined , I just didn’t put it here in the post because it’s obvious what it means.
2 - The mode of increasing and decreasing the frame that you gave I had already tried, it gives the same thing
3 - This variable is defined!

i assume you want the frame to scale based on resolution

while i don’t know how to code that in, i have a suggestion that i suggest to everyone

I don’t need that, as shown in the image it’s a user’s own setting, which makes him can move, increase and decrease and set the transparency of the frame

if you want to change transparency based on the slider’s progress, you need to get the position of the “zipper” (the green square)

i’m boldly going to assume you’re using drag detectors, based on the fact i have not seen .DragContinue as an event ever

(aren’t drag detectors studio only??)

i don’t really know the structure of your gui, but you want to do something like this:

local transparency = zipper.Position.X / sliderBar.Size.X -- this will only work if the zipper is a child of the slider bar

frame.Transparency = transparency

the problem to be solved is what I wrote in the post, in the case of increasing and decreasing the frame, the method is in LuaU above

bro what do you mean by INCREASES and DECREASES

be more SPECIFIC

Did you see the video that is in the post?