Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How should I go about making a ScreenGui Chatlog - thing?

ScreenGui Setup

This is how I have my ScreenGui and ScrollingFrame set up. I have an idea: When any player in the game chats into the chat, it will change the text of a TextLabel onto the ScrollingFrame. The only thing I'm stuck on is how to make a new TextLabel every time a player chats, and how to make it not overlap eachother.

for i,v in pairs(game:GetService("Players"):GetChildren()) do
v.Chatted:Connect(function(msg)
 -- I'm stuck here.
 end)
 end

Could I get some help please?

1 answer

✓ Accepted answer

In order to create new TextLabels, you would simply use Instance.new() or :Clone a pre-existing one.

local newlabel = Instance.new("TextLabel", script.Parent.Frame)
newlabel.Text = msg
newlabel.Position = UDim2.new(0, 0, 0, 0)

This simply changes the new TextLabel's text to whatever the last message.

Second, in order to move all the TextLabels downwards, you would have a 'for loop' that would take all the labels and position them downwards. This should go BEFORE the above code.

local messages = script.Parent.Frame:GetChildren() -- Where ever textlabels are stored
for a = 1, #messages do
	messages[a].Position = messages[a].Position + UDim2(0, 0, 0, 0)
end

The code here is not reliable so i'd advise you to not directly copy it but improve upon it. Also the note the positioning depends on the size of your text labels, which is up to you. Good luck.

1 comment

0

I have a question: I tweaked the code, and, I get the error: " 00:31:38.435 - Players.KDarren12.PlayerGui.ScreenGui.Script:6: attempt to call global 'UDim2' (a table value)", what do I do?

This discussion is preserved as it was. New answers, comments, and votes are closed.