Gui GetChildren() / obj.Parent problem

In a Gui, I use getChildren() with a for to move items from the GUI to another place, only she doesn’t want this to move anymore and there is no error. Its worked before but is no longer work and i don’t have backup of before.
This is a localScript

	local plrMessageFolder = Instance.new("Folder")
	if not messages:FindFirstChild(plr.Name) then
		plrMessageFolder.Parent = messages
		plrMessageFolder.Name = plr.Name
	end

				for i, obj in pairs(messageScrollingFrame:GetChildren()) do
					print("called")
					if obj:IsA("TextButton") then
						print("moved")
						obj.Parent = plrMessageFolder
					end
				end

In my console,called and moved is printed but the obj.Parent don’t change
(plr is a player Object)

Can you show the whole script?

This should be good for trying the script

-Script removed

If you add a print below here:

print(obj.Parent.Name)

What does it print?

Its print this :
image (there are not moved)

Could you try parenting the obj to the workspace, instead of the plrMessageFolder. I wonder if the problem has to do with the Parenting, or if it is a problem with the plrMessageFolder.

1 Like

Its working… this is a problem with the Gui ? plrMessageFolder exist so idk why this is not working

Do i change it with messages[plr.Name] ?

1 Like

Yes that should work I think. I believe that the problem might have been that you only parent the folder in an if loop. If the if statement doesn’t trigger, the folder is parented to “nil” so you can’t parent anything to it.

No :confused: this is not working. Do this will due to the Configuration Folder?image

Sorry I don’t understand what you mean by “Do this will due”. Could you clarify a little more.

Also it didn’t work when you did:

obj.Parent = messages:FindFirstChild(plr.Name)

Yes, it’s not working

Well basically, instead of Configuration I used a Folder except that these are bugged in the Gui and so i was wondering if the config files were too

Yeah then Idk :frowning: . Would it send parent them to the folder “Player2” if you tried:

obj.Parent = messages.Player2

Maybe if instead of creating a file in the GUI I created one in the local player object it would work?

Yeah try that. Also did what I say here:

change the parent or no.

Its working. I am lost now. It looks like Plr.Name does not work but yet when I print it the right name

Then the plr name must be wrong. When you call the function addUserInList(plr), are you sure that you call it with the player. Try at the very top printing

print(plr.Name)

Does it print the name of the player?

Its printing the good name image

Wow this is so confusing. Maybe see if this prints the correct folder:

if obj:IsA("TextButton") then
	print("moved")
    local  folderToMove = messages:FindFirstChild(plr.Name)
    print(folderToMove.Name, folderToMove.Parent)
	obj.Parent = folderToMove
end

I have to go, I can help you in a couple hours. Goodluck with your script :slight_smile: !

From what I know the Configuration instance is used for storing Value objects.

I don’t know if things inside there don’t work if they’re not a value object, but try replacing the messages configuration folder instance with a regular folder.