If statement help

So I’m looping through children of a frame, then looping through frames in that frame. But right now I’m trying to make the script only loop through the frames inside the parent frame, but what I’m doing isn’t working and it loops through all the children of the frame anyway. You can also ignore all the table stuff, that’s for a datastore

while wait(15) do
	for i, player in pairs(game.Players:GetPlayers()) do
		local Settings = {}
		for i, v in pairs(player.PlayerGui.ScreenUI.Settings.BigScroll.RescaleFrame:GetChildren()) do
			if v:IsA("Frame") and v.Name ~= "Description" then -- This is the line that's not working correctly. 
				for i, object in pairs(v:GetChildren()) do
					local Setting = {}
					Setting["Name"] = v.Name
					if object.YesNo.Image == "http://www.roblox.com/asset/?id=6302778252" then
						Setting["Check"] = false
					else
						Setting["Check"] = true
					end
					Setting["SettingType"] = object.Parent.Name
				end
			end
		end
	
		local json = HttpService:JSONEncode(Settings)
		SettingData:SetAsync(player.UserId, json)
	end
end

I would suggest breaking it into two if statements

if v:IsA('Frame') then
    print('Check 1')
    if not v.Name == 'Description' then
        print('All good')
    end
end

if not v.Name == 'Description' then

This wouldn’t work because of how Lua handles the order of logical operations. Instead, it should be
if not (v.Name == 'Description') then
or
if v.Name ~= 'Description' then
(Which was what he used)

I imagine your problem has to do with a basic logical problem with how you’re looping through it

For example, if you checked only the parent frames but not the children of the frames

Would you mind showing us the GUI setup in the explorer, because I dont see any problems with your code?

settingsex

Do you want it to loop through only GlobalShadows and SunRays?

Yes that’s what I’m trying to do.

You would want to add another

if v:IsA("Frame") then

In the next loop too
For example:

for i, v in pairs(player.PlayerGui.ScreenUI.Settings.BigScroll.RescaleFrame:GetChildren()) do
			if v:IsA("Frame") and v.Name ~= "Description" then -- This is the line that's not working correctly. 
				for i, object in pairs(v:GetChildren()) do
                     if v:IsA("Frame") then
2 Likes