How do I make script run through these badges?

Just use a loop:

for i, battery in Batteries:GetChildren() do
	battery.BasePart:GetPropertyChangedSignal("Color"):Connect(function()
		if workspace.MyCoolPart.Color == Color3.fromRGB(0, 47, 255) then
			return
		end
		
		local allGreen = true

		for i, otherBattery in Batteries:GetChildren() do
			if otherBattery.BasePart.Color ~= ColorGreen then
				allGreen = false
			end
		end

		if allGreen then
			workspace.MyCoolPart.Color = Color3.fromRGB(0, 47, 255)
		end
	end)
end
1 Like

For some reason, it gives me this error:

RobloxStudioBeta_Y3YkCA4K03

This is what the folder looks like under workspace:
RobloxStudioBeta_uNwaGJlTs6

I accidentally typed an extra i in GetChildren(), used my edited script.

1 Like

Wouldn’t I need to use GetDescendants() instead of GetChildren() here?
RobloxStudioBeta_1VJBn5N5Du

Because the BasePart is found in a model inside the batteries folder (the BasePart is what will change colors)
RobloxStudioBeta_rZNvQVCHE5

No, just use otherBattery.BasePart. Sorry for forgetting to add stuff in again lol, check my edited script.

1 Like

Seems like everything is working perfectly! Thank you @Katrist & @PsyIex so so much for heavily assisting me in this, I appreciate it so much :heart:

2 Likes

No Problem! It always makes me happy to help out others :).

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.