Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
KDarren12 705 Donator Moderation Voter
5 years ago

!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

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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.

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? KDarren12 705 — 5y
Ad

Answer this question