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?
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)
```
ActualSlot is not defined anywhere in the script. It should be defined before being used.
In the SizeFrame condition, there are issues with the calculations for SizeX and SizeY.
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)
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 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