Hello.
I am trying to make multiple parts untransparent using the for i, in pairs script. I am very new to this function, so I am not sure what I did wrong!
I tried to alter the script but nothing seemed to work for me. I was able to get my lights to enable, but for some reason, the transparency stays the same.
Here is my script
for i, v in pairs(LightFolder:GetDescendants()) do
if v:IsA("Light1") then
v.Transparency = 0
end
if v:IsA("Light2") then
v.Transparency = 0
end
for i, v in pairs(LightFolder:GetDescendants()) do
if v:IsA("SurfaceLight") then
v.Enabled = true
end
if v:IsA("PointLight") then
v.Enabled = true
end
end
end
Your if v.Name == "whatever your name is here" then script worked. Thank you very much. I did not know that you had to ask for a name in order to call a part. Well now I know one more thing! Thank you.
Here is my script now.
for i, lights in pairs(LightFolder:GetDescendants()) do
if lights.Name == "Light1" then -- Thank you, Intechill
lights.Transparency = 0
end
if lights.Name == "Light2" then
lights.Transparency = 0
end
end
IsA checks if the Instance is under a specific class, which will return as true or false depending if it is or if it isn’t
If your Part’s name is Light1, that will only change its Name, Not its class, each Instance has a property known as ClassName which will tell you what it is, If you have a Part, it would be a Part, if you name it as myPart, its class is still a Part no matter what.
I’m not sure how you missed the part that IsA checks for Classes, Its Literally in it’s Description and its Sample Code.