Im currently practicing for loops and functions but the material does not revert, whats wrong in the script?
local TestParts = game.Workspace.Folder:GetChildren()
local tim = game.Lighting.TimeOfDay
function UpdateToNeon()
for i, v in pairs(TestParts) do
v.Material = "Neon"
print("Material Updated for Index "..i)
wait(1)
end
end
function UpdateToPlastic()
for i, v in pairs(TestParts) do
v.Material = "Plastic"
print("Material Updated for Index "..i)
wait(1)
end
end
function AltChange()
for i, v in pairs(TestParts) do
if v.Material == "Plastic" then
UpdateToPlastic()
else
UpdateToNeon()
end
end
end
AltChange()
you need to do == instead of = when you’re writing an if statement.
instead of “Plastic” and “Neon” it’s Enum.Material.Neon and Enum.Material.Plastic.
also, what are you trying to make? the script goes through all the parts in TestParts, checks if the part is either plastic or neon, then changes all of the parts parts in TestParts to plastic or neon depending on which function was called. Is that what you meant to do?
local TestParts = game.Workspace.Folder:GetChildren()
local tim = game.Lighting.TimeOfDay
function UpdateToNeon()
for i, v in pairs(TestParts) do
v.Material = Enum.Material.Neon
print("Material Updated for Index "..i)
wait(1)
end
end
function UpdateToPlastic()
for i, v in pairs(TestParts) do
v.Material = Enum.Material.Plastic
print("Material Updated for Index "..i)
wait(1)
end
end
function AltChange()
for i, v in pairs(TestParts) do
if v.Material == Enum.Material.Plastic then
UpdateToPlastic()
else
UpdateToNeon()
end
end
end
AltChange()