So I’m using a UiListLayout and make some sorta message system in which their is max message and i want the newest message to be first than the second newest to the oldest and I store the oldest and delete it but it seems to break the order for some reason
local function RecieveMessage(message)
local Data = message.Data
local UserId = Data.UserId
local messageFrames = {}
for _, child in ipairs(MessageFrame:GetChildren()) do
if child:IsA("Frame") then
table.insert(messageFrames, child)
end
end
if #messageFrames >= MaxMessages then
local FirstMessage = messageFrames[1]
FirstMessage:Destroy()
end
local NewMessage = script.MessageFrame:Clone()
NewMessage.MessageLabel.Text = Data.Message
NewMessage.ProfileImage.Image = game.Players:GetUserThumbnailAsync(UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size60x60)
NewMessage.Parent = MessageFrame
NewMessage.LayoutOrder = 1
for i, Msg in ipairs(messageFrames) do
Msg.LayoutOrder = i + 1
end
table.insert(messageFrames, 1, NewMessage)
end
right now the script just goes in order for eg. a , b , c , d , e , f | Im trying to make it go f , e , d , c , b , a