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

How to set all decals with a name?

for i,child in pairs(parent:GetChildren()) do
	if child:IsA('Decal') and child.Name == 'Science' then
		child.Texture = "http://www.roblox.com/asset/?id=3916138491"-- or Child.Locked = true
	end
end

i am trying to make it when the game starts any decals with the name Science it will change there texture to this http://www.roblox.com/asset/?id=3916138491

2 answers

✓ Accepted answer

Your code is perfect! You just needed to add "script" into the first line, shown here:

for i, child in pairs(parent:GetChildren()) do

to

for i, child in pairs(script.Parent:GetChildren()) do

for i, child in pairs(script.Parent:GetChildren()) do -- Going through the children
	if child:IsA('Decal') and child.Name == 'Science' then -- Is it a decal? Is it's name "Science"?
		child.Texture = "http://www.roblox.com/asset/?id=3916138491" -- Let's change it!
	end
end

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