Gui & Scripting(Position problem)

Hi, i have this script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local RemoteEvent = ReplicatedStorage:WaitForChild("Send(ed)Message") 
local player = Players.LocalPlayer
local gui = script.Parent
local scrollingFrame = gui:WaitForChild("SideBar"):WaitForChild("ChatCorner")
local MAX_BUBBLES = 25
local BUBBLE_SPACING = 10
local BSPBubble = script.Parent.ChatBubble
local function createBubble(message)
	local chatBubbleFolder = script.Parent.SideBar.ChatCorner.Bubbles -- Der Ordner, in dem sich die Chat-Bubbles befinden
	local newBubble = script.Parent.ChatBubble:Clone() -- Erstellt eine Kopie des ChatBubble-Objekts
	newBubble.Position = UDim2.new(-0, 0,0.929, 0)
	newBubble.Text.Text = message -- Setzt den Text der neuen Bubble auf die übergebene Nachricht
	newBubble.Position = newBubble.Position + UDim2.new(0,0,0,(newBubble.Text.TextBounds.Y + 2))
	warn("Message is now inside")
	newBubble.Parent = chatBubbleFolder -- Setzt den Parent der neuen Bubble auf den Bubbles-Ordner
	local bubbles = 0
	newBubble.Name = "Bubble:50"
	newBubble.Visible = true
	--newBubble.Position = UDim2.new(0.076, 0,0.128, 0)

	local textBounds = newBubble.Text.TextBounds
	newBubble.Size = UDim2.new(0,(newBubble.Text.TextBounds.X + 10), 0, (newBubble.Text.TextBounds.Y +10))

		for _, bubble in ipairs(chatBubbleFolder:GetChildren()) do
		if bubble ~= newBubble then
			bubble.Position = bubble.Position + UDim2.new(0, 0, 0, (0 - (25)))
			end
		end
	
ls
		local topBubble = chatBubbleFolder:GetChildren()[1]
		if topBubble.Position.Y.Offset + topBubble.Size.Y.Offset > script.Parent.SideBar.ChatCorner.AbsoluteSize.Y then
			topBubble:Destroy()
		end
	
	for i,Bubbles in ipairs(chatBubbleFolder:GetChildren()) do
		bubbles += 1
	end
	if not (bubbles <= 1) then
		local twoetubble = chatBubbleFolder:GetChildren()[bubbles-1]
		warn(twoetubble.Name)
		twoetubble.Position = twoetubble.Position + UDim2.new(0,0,0,(newBubble.Text.TextBounds.Y + 50))
	end
	warn(bubbles)
	newBubble.Name = tostring("Bubble:"..(bubbles - 1))
end



RemoteEvent.OnClientEvent:Connect(function(message)
	warn("Got the message"..message)
	local bubble = createBubble(message)
	warn("Created the Bubble")
end)

Waht I want vs waht I have.

  1. message, but problem.

    Hirachie:
    GUI2
    ChatCorner:

    I want the news to stay in this area.

Thank you for your help, I really do not know more!

just use a uilistlayout and set the verticalalignment to bottom

1 Like

Ah thanks, but how do I make the size adjust to the size I need?

Could check if the text fits, if it doens’t just add some size until it fits.

But how? I have the text size fixed at 18.

Jst with the property if TextLabel.TextFits: TextLabel | Documentation - Roblox Creator Hub