Hello, fella devs,
I’m trying to make a game settings/option with local script and trying to load the settign data. But, the data didn’t do anything. Can you help me?
localGameOptions
local Lighting = game:GetService("Lighting")
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local events = ReplicatedStorage:WaitForChild("Events")
local functions = ReplicatedStorage:WaitForChild("Functions")
local loadOptionSettings = functions:WaitForChild("loadOptionSettings")
local sendContrast = events:WaitForChild("sendContrastSetting")
local sendShadow = events:WaitForChild("sendShadowSetting")
local sendFog = events:WaitForChild("sendFogSetting")
local gui = script.Parent
local options = gui.Options
local back = gui.Back
options.HighContrast.StatusBtn.Activated:Connect(function()
if options.HighContrast.Status.Value == false then
options.HighContrast.Status.Value = true
local contrast = Instance.new("ColorCorrectionEffect")
contrast.Name = "Contrast"
contrast.Contrast = 0.3
contrast.Parent = Lighting
options.HighContrast.StatusBtn.Image = "rbxassetid://5578470911"
else
options.HighContrast.Status.Value = false
if Lighting:FindFirstChild("Contrast") or Lighting:FindFirstChildOfClass("ColorCorrectionEffect") then
local objet = Lighting:FindFirstChild("Contrast") or Lighting:FindFirstChildOfClass("ColorCorrectionEffect")
objet:Destroy()
end
options.HighContrast.StatusBtn.Image = ""
end
sendContrast:FireServer(options.HighContrast.Status.Value)
end)
options.Shadow.StatusBtn.Activated:Connect(function()
if options.Shadow.Status.Value == true then
options.Shadow.Status.Value = false
Lighting.GlobalShadows = false
options.Shadow.StatusBtn.Image = "rbxassetid://5578470911"
else
options.Shadow.Status.Value = true
Lighting.GlobalShadows = true
options.Shadow.StatusBtn.Image = ""
end
sendShadow:FireServer(options.Shadow.Status.Value)
end)
options.Fog.StatusBtn.Activated:Connect(function()
if options.Fog.Status.Value == false then
options.Fog.Status.Value = true
local fade = TweenService:Create(Lighting, TweenInfo.new(1), {FogEnd = 30})
fade:Play()
options.Fog.StatusBtn.Image = "rbxassetid://5578470911"
else
options.Fog.Status.Value = false
local fade = TweenService:Create(Lighting, TweenInfo.new(1), {FogEnd = 1000})
fade:Play()
options.Fog.StatusBtn.Image = ""
end
sendFog:FireServer(options.Fog.Status.Value)
end)
game.Players.PlayerAdded:Connect(function(player)
local optionSettings = loadOptionSettings:InvokeServer(player)
if optionSettings["HighContrast"] then
options.HighContrast.Status.Value = true
local contrast = Instance.new("ColorCorrectionEffect")
contrast.Name = "Contrast"
contrast.Contrast = 0.3
contrast.Parent = Lighting
options.HighContrast.StatusBtn.Image = "rbxassetid://5578470911"
else
options.HighContrast.Status.Value = false
if Lighting:FindFirstChild("Contrast") or Lighting:FindFirstChildOfClass("ColorCorrectionEffect") then
local objet = Lighting:FindFirstChild("Contrast") or Lighting:FindFirstChildOfClass("ColorCorrectionEffect")
objet:Destroy()
end
options.HighContrast.StatusBtn.Image = ""
end
if optionSettings["Shadow"] then
options.Shadow.Status.Value = false
Lighting.GlobalShadows = false
options.Shadow.StatusBtn.Image = "rbxassetid://5578470911"
else
options.Shadow.Status.Value = true
Lighting.GlobalShadows = true
options.Shadow.StatusBtn.Image = ""
end
if optionSettings["Fog"] then
options.Fog.Status.Value = true
local fade = TweenService:Create(Lighting, TweenInfo.new(1), {FogEnd = 30})
fade:Play()
options.Fog.StatusBtn.Image = "rbxassetid://5578470911"
else
options.Fog.Status.Value = false
local fade = TweenService:Create(Lighting, TweenInfo.new(1), {FogEnd = 1000})
fade:Play()
options.Fog.StatusBtn.Image = ""
end
end)