I’m working on a system where you run a chat command and you receive a custom notification depending on the result of the command.
Everything works, except for the fact that whenever there are multiple notifications at the same time, parented to a ScrollingFrame, and the UIListLayout Vertical Alignment is set to bottom, the first notification that the player received gests cut off and there’s a ton of blank space between the last notification and the end of the ScrollingFrame (this space actually corresponds to the space that gets cuts off from the first notification)
To keep this simple I’m gonna demonstrate it in the following attached video with just normal Frame items instead of the actual notification I’m using.
Please let me know if you have any ideas about how to fix this by keeping the Vertical Alignment set to bottom (That’s kinda necessary because I want the last received to notification to show up at the bottom and the older ones to be at the top)
Scrollingframes aren’t built to expand upwards, they’ll always expand down, so there’s not a whole lot you can do here. Most games will have it inside a frame and just let the notifications just infinitely go upwards, and delete the one at the bottom after a few seconds. I imagine this would be your best option since you wouldn’t really need to have too many notifications going off at once
I was finally able to solve the issue by disabling AutomaticCanvasSize on the ScrollingFrame and by manually updating the CanvasSize and CanvasPosition in the notification script by adding the following to add a new notification:
local ScrFrame = game.Players.LocalPlayer.PlayerGui.Notifications.Main.ScrollingFrame
if (#ScrFrame:GetChildren() - 1) == 0 then
ScrFrame.CanvasSize = UDim2.new(0, 0, 0, 150)
else
ScrFrame.CanvasSize = UDim2.new(0, 0, 0, ScrFrame.CanvasSize.Y.Offset+160)
end
--This was an absolute lifesaver (It auto-scrolls the ScrollingFrame when a new notification appears)
ScrFrame.CanvasPosition = Vector2.new(0, ScrFrame.UIListLayout.AbsoluteContentSize.Y)
--
And this when removing an old one:
if (#ScrFrame:GetChildren() - 1) == 1 then
ScrFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
else
ScrFrame.CanvasSize = UDim2.new(0, 0, 0, ScrFrame.CanvasSize.Y.Offset-160)
end