Try using for loops!
for i, v in pairs(Workspace:GetChildren()) do
if v:IsA"BasePart" and v.Name == "Lava" or v.Name == "Acid" then
v.Transparency = 0.5
v.Reflectance = 0.5
end
end
wait(0.5)
for i, v in pairs(Workspace:GetChildren()) do
if v:IsA"BasePart" and v.Name == "Lava" or v.Name == "Acid" then
v.Transparency = 0.5
v.Reflectance = 0.2
end
end
for loop can be used to search through any object for it's children, making it excellent at searching objects with same name.
This will make script search through all the Workspace for a part named either "Lava" or "Acid". When it finds part/parts, it/they will change respectively to your likings.
There are two for loops because the first one makes Reflectance of those part 0.5, and the second on turn the Reflectance to 0.2. If there was one loop and wait(0.5) was in the middle (see below), that would make it so it changes parts one by one, rather than every at once.
for i, v in pairs(Workspace:GetChildren()) do
if v:IsA"BasePart" and v.Name == "Lava" or v.Name == "Acid" then
v.Transparency = 0.5
v.Reflectance = 0.5
wait(0.5)
v.Transparency = 0.5
v.Reflectance = 0.2
end
end
Note: v:IsA"BasePart" makes sure that it's a part, not script so you don't end up changing Reflectance of a script named Acid or Lava.
2 comments
when you say
local p = "Lava, Acid"All your doing is defining p as a string that is "Lava,Acid". If you want to change everything in the workspace, you need to use a for loop.Ah, okay.