Changing Decals in more than 2 models

Hello everyone!

I would want to know how does one change decals in 2+ models,

Instead of doing:

Flag1.Decal.Texture = "rbxasset://0"
Flag2.Decal.Texture = "rbxasset://1"

I did:

for i, Flag in pairs(Flags:GetChildren()) do
			
			for i, FlagChild in pairs(Flag:GetChildren()) do
				
				if FlagChild.Name == "Flag" then
					
				for i, FlagDecal in pairs(FlagChild:GetChildren()) do
						if FlagDecal:IsA("Decal") then
							if plr.TeamColor == BrickColor.new("Dark stone grey") then 
								FlagDecal.Texture = "rbxassetid://1"
							elseif plr.TeamColor == BrickColor.new("Deep orange") then
								FlagDecal.Texture = "rbxassetid://0"
							end
						end
					end
				end
			end
		end

But my script doesn’t work, and I don’t get any errors in the output.

EDIT: The hierarchy of the Flags:

Any help would be appreciated!

just use getdescendants instead of getchildren, this returns all the instances in that group/folder

Can you show the hierarchy of the Flags in the explorer

also if you’re gonna use multiple if statements pair them up with and

still doesn’t work
30 c h arrssssssss

try

local Player = whatever.Parent
local Flags = whatevermodel.Parent

for index, Decal in pairs(Flags:GetDescendants()) do
if Decal:IsA("Decal") and Player.TeamColor == BrickColor.new("COLORHERE") then
-- function here
elseif Decal:IsA("Decal") and Player.TeamColor == BrickColor.new("COLORHERE") then
-- function here
      end
end

Are you sure the TeamColors are correct? Because it’s working for me in studio

local Flags = workspace:WaitForChild'Flags'
for i, Flag in pairs(Flags:GetChildren()) do
	for i, FlagChild in pairs(Flag:GetChildren()) do
		if FlagChild.Name == "Flag" then
			print(FlagChild:GetFullName())
			for i, FlagDecal in pairs(FlagChild:GetChildren()) do
				if FlagDecal:IsA("Decal") then
					print'Changing flag decal'
				end
			end
		end
	end
end	


image

here is my full script, and it doesn’t work:

ProximityPrompt.Triggered:Connect(function(promptObject, plr)
	if NeutralizedV.Value == false then
		for i, Flag in pairs(Flags:GetDescendants()) do
			
			for i, FlagChild in pairs(Flag:GetDescendants()) do
				
				if FlagChild.Name == "Flag" then
					
					for i, FlagDecal in pairs(FlagChild:GetDescendants()) do
						if FlagDecal:IsA("Decal") and plr.TeamColor == BrickColor.new("Dark stone grey") then
								FlagDecal.Texture = "rbxassetid://1"
						if FlagDecal:IsA("Decal") and plr.TeamColor == BrickColor.new("Deep orange") then
								FlagDecal.Texture = "rbxassetid://0"
							end
						end
					end
				end
			end
		end
	end
end)

EDIT: I think I realized, I just forgot to set the NeutralizedV.Value to false in studio
EDIT2: nope, still didnt work

Ok, so it was a problem in some value or in the player statement, but I fixed it now. Thank you everyone for helping!