Why does my script not detect the change of value nor do its function?

Well, I have had this problem for a long time and I don’t know how to solve it, the truth is that this script “changes” the Brightness, globalShadows and ShadowsSoftness. The script must detect a value and depending on the value, the function must make a change (bajo, Medio and Alto). But these functions are not performed and the value is not detected. It doesn’t give any error or anything.

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

StringValueShadow:GetPropertyChangedSignal("Value"):Connect(function()
	wait()
	if StringValueShadow.Value == "Bajo" then
		for _, item in ipairs(workspace:GetDescendants()) do
			if item:IsA("PointLight") then 
				Lighting.GlobalShadows = false
				Lighting.ShadowSoftness = 1
			end
			item.Shadows = false
			item.Brightness = 0.35
		end
	elseif StringValueShadow.Value == "Medio" then 
		for _, item in ipairs(workspace:GetDescendants()) do
			if item:IsA("PointLight") then 
				Lighting.GlobalShadows = true
				Lighting.ShadowSoftness = 0.5
			end
			item.Shadows = false
			item.Brightness = 0.35
		end
	elseif StringValueShadow.Value == "Alto" then 
		for _, item in ipairs(workspace:GetDescendants()) do
			if item:IsA("PointLight") then 
				Lighting.GlobalShadows = true
				Lighting.ShadowSoftness = 0.1
			end
			item.Shadows = true
			item.Brightness = 0.75
		end
	end
end)
1 Like

Why don’t you just use StringValueShadow.Changed as the event?

Edit: And since you’re using local player I’m assuming this is a local script? If it is that’s why nothing is happening, I’d think you’d get an error but maybe not. Try firing a remote event from your client to the server to change the lighting properties.

1 Like

Does the script generally work? If it doesn’t, you are probably parenting it incorrectly where it does not function at all. Server changes will change as accordingly on client, which shouldn’t be a problem(this only applies the other way though).

1 Like

Well, it doesn’t give any error, the script detects the value of a StringValue and that value is changed by a DataStore, and then the previous script should detect the value …

1 Like