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

How do I make my in pairs script change materials?

local TableOfBlocks = game.workspace.Blocks:GetChildren()

for i, v in pairs (TableOfBlocks) do
	v.Material = "Neon"
end

Blocks is a model filled with about 5 blocks that are exact duplicates of each other.

I am trying to make the value (The children of Blocks) material change.

I do not know why this will not change the blocks material to neon.

Please tell me how to get this to work.

1 answer

✓ Accepted answer

You have the right idea, but you have to use Enum keyword to change materials.

local TableOfBlocks = game.workspace.Blocks:GetChildren()

for i, v in pairs (TableOfBlocks) do
    v.Material = Enum.Material.Neon
end

2 comments

0

its also better to use "for _," intead of "for i,"

0

I forgot all about enum, I don't know why,

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