Instance's name is Value?

Hello! So I’m trying to make Chatlogs, but for some reason the Instance’s name is Value. Script:

--1. Script:
		local Chat = game:GetService("Chat")
		local ReplicatedStorage = game:GetService("ReplicatedStorage")
		local ChatStorage = ReplicatedStorage.ChatStorage
		--Filter the message and add it to ChatStorage
		local filteredMessage = Chat:FilterStringAsync(tostring(msg), plr, plr)
		--Now create a new instance
		local message = Instance.new("StringValue", ChatStorage)
		message.Name = plr.Name..": "..filteredMessage
		message.Value = plr.Name..": "..filteredMessage
	--Works fine, btw it adds the Instance to ChatStorage, also it names it after the plr.Name..": "..filteredMessage

--2. Script: 
local ChatStorage = game.ReplicatedStorage.ChatStorage
local scrollingFrame = script.Parent
ChatStorage.ChildAdded:Connect(function(child)
	--So that 1 becomes 2, 2 becomes 3 etc.
	scrollingFrame:FindFirstChild("1").Text = child.Name --For some reason it just says Value
end)


image

This is because of Task Scheduler.

First, the ChildAdded listens to a child being added. Now, look at the line Instance.new, it seems like you already parented it. Now, due to this, the ChildAdded is fired before setting the value.

Fix:

Before parenting it, set the value first.

1 Like

The name was probably changed too slow, try adding a wait() in the ChildAdded.

ChatStorage.ChildAdded:Connect(function(child)
	wait(2)
	scrollingFrame:FindFirstChild("1").Text = child.Name --For some reason it just says Value
end)
1 Like

Yep, works fine like that. Thank you!
image