Parts not turning into desired transparency

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
1 Like

ah yes if v:IsA("Light1") then its if v:IsA("PointLight") then or whatever type of light you’re using

(if you are looking for the name of a part)

if v.Name == "whatever your name is here" then
1 Like

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
1 Like

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.

You can even read it here.

1 Like

Okay, this will be useful. Thank you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.