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)