I need help with script (GetChildren)

Output Error: Visible is not a valid member of UIListLayout "Players.LovelySunLilac.PlayerGui.RadioGui.Frame.ChatFrame.UIListLayout"

Script:

script.Parent.ChangeFrequency.Event:Connect(function(freq)
frequency = freq
for _,msg in pairs(script.Parent.ChatFrame:GetChildren()) do
msg.Visible = false
script.Parent.ChatFrame.CanvasSize = UDim2.new(0,0,0,0)
end

What is the precise object you are trying to disable the “Visible” property off? A TextLabel?

Something you could do is this;

script.Parent.ChangeFrequency.Event:Connect(function(freq)
    frequency = freq
    for _,msg in pairs(script.Parent.ChatFrame:GetChildren()) do
        if msg:IsA("TextLabel") then -- replace this by whatever object you want to change
            msg.Visible = false
        end
        script.Parent.ChatFrame.CanvasSize = UDim2.new(0,0,0,0)
    end
end)

(Thanks to @NyrionDev who told me in DMs that I forgot two end statements.)

3 Likes

That should work, if the “TextLabel” thing doesn’t work, he can just change it.

UIListLayouts don’t have a “Visible” property you just need to add a conditional to that loop which checks the type of instance being iterated over.

1 Like
script.Parent.ChangeFrequency.Event:Connect(function(freq)
    frequency = freq

    for _, msg in pairs(script.Parent.ChatFrame:GetChildren()) do
        if msg.Name ~= "UIListLayout" then
            msg.Visible = false
        end

        script.Parent.ChatFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
    end
end)

The error was caused by “UIListLayout”, within ChatFrame. The problem was when you looped through it, the system also found “UIListLayout”, which doesn’t have a Visible property causing the error!

1 Like

What if the UIListLayout’s name has been changed?

if not msg:IsA("UIListLayout") then
if msg.ClassName ~= "UIListLayout" then

Would be better.

1 Like