How to keep the notification UIs have the same spacing regardless of how fast they are being called?

Hello everyone,

I’m making a notification system and stumbled upon an issue.

in my notification UI they are supposed to be spaced like this:
notifcation

they would be spaced like this if the function to create them doesn’t call them fast, However if the script is called fast then this occurs:
notifcation2

as you can see the spacing is almost non existent and I want them to be spaced like the first picture regardless of how fast the script is being called at

here is the script responsible for that:

local function ManageExessive(Player)
	local LastFrame = 0

	for i,v in ipairs(Player.PlayerGui.PopupUI.PopupFrame:GetChildren()) do
		if v:IsA("Frame") then

			local Tween = TweenService:Create(v,TweenInfo.new(0.05), {Position = v.Position - UDim2.fromScale(0,0.12)})
			Tween:Play()

			if v.Position.Y.Scale < 0  or v.Position.Y.Scale - 0.12 < 0 then
				local Event 
				local Tween = TweenService:Create(v,Tweeninfo, {Size = v.Size - UDim2.fromScale(0.9,0), BackgroundTransparency = 1})
				Tween:Play()
				Event = Tween.Completed:Connect(function()
					v:Destroy()
					Event:Disconnect()
				end)
			end		


		end
	end
end

local GuiFunction = {}



local function Showpopup(Player,TweenedUi,ExtraUI)

	ManageExessive(Player)

	local SizeTween = TweenService:Create(TweenedUi,Tweeninfo, {Size = TweenedUi.Size + UDim2.fromScale(0.9,0) , BackgroundTransparency = 0})
	local StrokeTween = TweenService:Create(TweenedUi.UIStroke,Tweeninfo,{Thickness = 1})
	local CloseTween = TweenService:Create(TweenedUi,Tweeninfo, {Size = TweenedUi.Size, BackgroundTransparency = 1 })
	local StrokeCloseTween = TweenService:Create(TweenedUi.UIStroke,Tweeninfo,{Thickness = 0})

	TweenedUi.Parent = Player.PlayerGui:WaitForChild("PopupUI").PopupFrame

	SizeTween:Play()
	StrokeTween:Play()
	SizeTween.Completed:Wait()
	for i,v in ipairs(ExtraUI) do
		if v:IsA("UICorner") or v:IsA("UIStroke") then continue end
		v.Visible = true
	end

	task.wait(2)
	if TweenedUi.Parent ~= nil then
		CloseTween:Play()
		StrokeCloseTween:Play()
		CloseTween.Completed:Wait()
		TweenedUi:Destroy()
	end	
end

Let me know if you have any questions, thank you.

Just use UIListLayout. No need to code that

2 Likes

Switch the holder frame for a scrolling frame, add a UIListLayout/UIGridLayout. If you want to make the newest at the top, make the scrolling frame’s SortOrder to LayoutOrder and make the newest one have a lower LayoutOrder.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.