Well, recently I realized that the Changed: Connect is not working properly, or at least with the shadows. The script detects the value of a stringValue, and that value when exiting, is saved, but I don’t know why it doesn’t detect it. I have another script the same, but it is with water, and that does work
local StringValueObject = game.Players.LocalPlayer:WaitForChild("Graficos"):WaitForChild("Shadow")
local Lighting = game:GetService("Lighting")
local Abrir = script.Parent.Parent.Parent.Parent:WaitForChild("Abrir")
StringValueObject.Changed:Connect(function()
if StringValueObject.Value == "Bajo" then
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
end
end
end
if StringValueObject.Value == "Medio" then
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
end
end
end
if StringValueObject.Value == "Alto" then
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)
Since your problem seems to be with ShadowSoftness, check that Lighting.Technology is properly configured, and that your device is capable of rendering the shadows.
Well I’ll explain briefly, a dataStore sets a value to a StringValue, and the value of the StringValue is detected by the script, when exiting and entering again, it should work as a data saving system, and it does not give any error.
I’m not sure if I fully understand what you’re trying to do. Is the issue only with saving to the DataStore when the player exits? If so then you should use game:BindToClose()
game:BindToClose(function()
-- save your values to the data store here
end)
Have you tried running the body of code within your changed event once initially? I assume what’s happening is the value already loads in by the time this code runs (hence the WaitForChilds) so therefor the event never fires.
I also assume this script runs when the player joins in the game, and data loads when said player joins in for the first time to assign data to these value objects.