How to use multiple values for just one script

Hello, I’ve been trying to do this for a while, I’ve been through the developer hub a lot and none of my issues have been resolved so I want some help.

An Example: I want to make a block turn red to do this I would use a basic script but I would have to do this for all the parts that are added and all the names and add to the script and that would be huge so I want to try to do a script for every time I add a BoolValue called IsColor, and all the parts that have this value are changed to the reddish color, if the part does not have this value, it is not changed so, not adding several part names and the script would be smaller

  1. I am aware of using only game.GetService("GetChildren"), but how would I use it to capture all values?

Hello how are you?

I’ll try to solve your problem, from what I understand you want that every time a children with a certain name is added to a certain part it changes color.

I believe this is the solution:

local Children = game.workspace:GetChildren()

for i = 1, #Children do
	if Children[i].Name == "PartChange" then
		
		Children[i].ChildAdded:Connect(function(child)
			if child.Name == "IsColor" then
				Children[i].BrickColor = BrickColor.new("Really red")
			end
		end)
		
	end
end
1 Like