Failed to change signal with GetPropertyChangedSignal

I explain briefly: This script should detect a value, and depending on the Value the part of the script should be executed. And then I discovered the elseif that saved me from many things. And then I wanted to put it in the localScript because the data did not load when entering the game if not after pressing the button that changes it. or the script does not work directly (without error in the output) or gives a mini crash (with error in the output)

local StringValueObject = game.Players.LocalPlayer:WaitForChild("Graficos"):WaitForChild("Shadow")
local Lighting = game:WaitForChild("Lighting")

StringValueObject:GetPropertyChangedSignal("Value"):Connect(function()

	if StringValueObject.Value == "Bajo" then end
	Lighting.GlobalShadows = false
	Lighting.ShadowSoftness = 1
	for _, item in ipairs(workspace:GetDescendants()) do
		if item:IsA("PointLight") then 
			item.Shadows = false
			item.Brightness = 0.35

		elseif StringValueObject.Value == "Medio" then end

		Lighting.GlobalShadows = true
		Lighting.ShadowSoftness = 0.5
		for _, item in ipairs(workspace:GetDescendants()) do
			if item:IsA("PointLight") then 
				item.Shadows = false
				item.Brightness = 0.35


			elseif StringValueObject.Value == "Alto" then end
			Lighting.GlobalShadows = true
			Lighting.ShadowSoftness = 0.1
			for _, item in ipairs(workspace:GetDescendants()) do
				if item:IsA("PointLight") then 
					item.Shadows = true
					item.Brightness = 0.75
				end
			end
		end
	end
end)

Why not use:

game:GetService("Lighting")

And also is there another child named “Graficos”? Or another child named “Shadow” inside Graficos?

I believe the issue is how you wrote the if statements.
This is how they should be written:

if something then
	--your code here
end

For your case:

if StringValueObject.Value == "Bajo" then
	Lighting.GlobalShadows = false
	Lighting.ShadowSoftness = 1
	...
end

Your problem is you are using ipairs where it shouldn’t be used. ipairs is used to iterate through a table’s indexes (will be a number of items in the table), therefore trying to call the IsA() function will give you an error. You should be using pairs in this case.

I changed it to how you put it and it keeps giving the same error.

I think it’s the issue with elseif, sometimes it’s broken, I’m not sure why. try another if statement. see if it works.

also i advice you to not use getdescendants its a bad practice maybe use like collectionservice and tags

Sorry for not answering, I have entered class and am doing homework. So what do you recommend?

Are you putting your ends in the correct place?

No, even if I put them correctly, it will not work either.