New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Frame's Y won't stay the same when the Canvas Size Y changes?

Asked by
Vezious 290 Moderation Voter
3 years ago

SFrame = ScrollingFrame

function Sort(NumberOfFrames,Pattern)
HideAll()
local Matched = 0
SFrame.CanvasSize = UDim2.new(0,0,(SFrameSize*(math.ceil((NumberOfFrames/2)))),0)
for i,Frame in pairs (script.Parent.Shop.Items:GetChildren()) do
local Match = string.match(Frame.Name,Pattern)
if Match then
Matched = Matched +1
Frame.Size = UDim2.new(.45,0,(ProductSize/(math.ceil((NumberOfFrames/2)))),0)

if Matched/2 ~= math.ceil(Matched/2) then
Frame.Position = UDim2.new(.025,0,Frame.Size.Y.Scale*((math.ceil(Matched/2))-1),0)
else
Frame.Position = UDim2.new(.525,0,Frame.Size.Y.Scale*((Matched/2)-1),0)
end

Frame.Visible = true
end
end
end

Also tried this:

function Sort(NumberOfFrames,Pattern)
HideAll()
local Matched = 0
SFrame.CanvasSize = UDim2.new(0,0,(SFrameSize*(math.ceil((NumberOfFrames/2)))),0)
for i,Frame in pairs (script.Parent.Shop.Items:GetChildren()) do
local Match = string.match(Frame.Name,Pattern)
if Match then
Matched = Matched +1
Frame.Size = UDim2.new(.45,0,(ProductSize/(SFrame.CanvasSize.Y.Scale/SFrame.Size.Y.Scale)),0)
if Matched/2 ~= math.ceil(Matched/2) then
Frame.Position = UDim2.new(.025,0,Frame.Size.Y.Scale*((math.ceil(Matched/2))-1),0)
else
Frame.Position = UDim2.new(.525,0,Frame.Size.Y.Scale*((Matched/2)-1),0)
end

Frame.Visible = true
end
end
end

What I'm trying to achieve.

There are 2 Buttons/Categories.

When you click one, it activates "Sort" which will select The Frames already made, and make them visible while making the other category's frames invisible. But if there are more frames in one category than the other, the frames are different sized.

I'm trying to make the frames stay the same size, no matter the Canvas Size. But the more # of Frames, the smaller it gets, and the more the image is deformed. What is wrong?

Yes, it has to be scaling

0
Help me :c Vezious 290 — 3y
0
Why does it have to use YScale if you don't want it to scale? Seems counterintuitive BlackJPI 2620 — 3y
0
So it's compatible with all devices/Screens Vezious 290 — 3y

Answer this question