Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Change Properties Of Objects With Same Name?

I need help.. There is 5 models in a game I made which are called "MORPH" and in each one of them they have a part called "HairColor" some have more then one in them.. I want to make the haircolor reflectance as 0 but when I used my old script that I don't have anymore it only did some of them as a reflectance of 0 because it was only doing 1 haircolor in each morph, some morphs have multiple haircolors as i said, so can anyone solve this?

In short form, 5 models in my game that is in the character is called MORPH and there is a part named HairColor in it, some have more then one haircolor in them and I want to change all "HairColor" parts reflectance to 0.

2 comments

0

Loop through them all through a for i,v in pairs loop.

0

delete your free models

2 answers

✓ Accepted answer

In the future, attempt to actually create your own script first.

modelParent = game.Workspace.part -- set this to whatever has the models in it.

for i,object in pairs(modelParent:GetDescendants()) do
	if object.Name == "HairColor" then
		object.Reflectance = 0
	end
end

1 comment

0

Also I recommend making this a plugin and running that so you don't have to run this every time the game starts.

Best way to "fix" this issue :

Well. Instead of asking it, you can actually do this thing. But you spend your own time by typing a for loop. You can just use a for loop and go through everything which have the same name, but it will take you longer, and it doesn't worth it. I recommend you to name them different.

Best way to fix this issue if it's about cloning :

Now a common error is people don't understand how to do this since they clone something. As we use cloning, we must use a variable to get through some properties/objects :

local Clone = game.Workspace.Part:Clone()

Now, how you change it's name? It's so basic.. just define the variable again and change it's name.

local Clone = game.Workspace.Part:Clone()
Clone.Name = "FixingErrorOfCloning"

This discussion is preserved as it was. New answers, comments, and votes are closed.