Help with my script

What’s wrong?

while true do
wait()
if script.Parent.SpoilerValue.Value == 1 then
for i,v in pairs(script.Parent.Spoiler1:GetChildren()) do
if v.Name == “Spoiler1” then
v.Transparency = 0
end
end

elseif script.Parent.SpoilerValue.Value == not 1 then
	for i,v in pairs(script.Parent.Spoiler1:GetChildren()) do
		if v.Name == "Spoiler1" then
			v.Transparency = 1
		end

		
	end
end	

end

An I see the hierarchy? It will give more info, so I know the mistake is not just wrong ordering.

elseif script.Parent.SpoilerValue.Value == not 1 then

Should be

elseif script.Parent.SpoilerValue.Value ~= 1 then

It’ll try to do script.Parent.SpoilerValue.Value == false which doesn’t work for your needs. I think it’s better to just use else for that case

Also, judging by your code, it’s better to use the Changed event of a BaseValue rather than using a while loop

1 Like