for _,child in pairs(game:GetChildren()) do local text = script.Parent text.Text = child.Name local newText = text:Clone() newText.Script:Destroy() newText.Parent = text.Parent newText.Visible = true end
You're getting that error because some children of game
aren't accessible to normal scripts. I don't know what you want to do so I can't suggest a better way, but if you really have to do it this way, use pcall
to prevent the errors, like so:
01 | for _,child in pairs (game:GetChildren()) do |
02 | pcall ( function () |
03 | local text = script.Parent |
04 | text.Text = child.Name |
05 | local newText = text:Clone() |
06 | newText.Script:Destroy() |
07 | newText.Parent = text.Parent |
08 | newText.Visible = true |
09 | end ) |
10 | end |