Hello, developers. I am making settings for my game, and I made it so they save. There is nothing wrong with the writing, or reading to the datastore. The problem is when it gathers the settings in the datastore stored as strings and enables them, they won’t enable. Clicking the settings works perfectly fine, but loading them in doesn’t. I’ve printed out the ImageTransparency of the checkbox, which prints 0 (visible) but every single time it’s invisible. I’ve ensured no other script is interfering with it, and I even made a loop so it is enabled and disabled. I’ve printed everything you can think of; enabled or disabled, transparency, setting name, and button. It just won’t work. It says the setting IS ON when I print it, but it is not on.
It also doesn’t help that this only occurs when I’m in the game and not Studio, so I can’t check the ImageTransparency property. I have to print it.
I honestly think this is an engine bug, but I really don’t know. Please help me, I am desperate!
(The print(“SHOWING IT OMGGGGGGGGGGG”) prints btw.)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local WriteDatastoreRemote = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("WriteDatastore")
local SettingsLoadedRemote = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("SettingsLoaded")
local Players = game:GetService("Players")
local settingsFrame = script.Parent
local ScrollingFrame = settingsFrame:WaitForChild("ScrollingFrame")
local ROBLOXMS = require(ReplicatedStorage:WaitForChild("ROBLOXMS"))
local Frames = {}
local LoadingSettings = true
function ToggleButton(Button: ImageButton, Frame: Frame)
Frames[Frame.Name].Toggled = not Frames[Frame.Name].Toggled
local Toggled = Frames[Frame.Name].Toggled
print(Toggled)
if Toggled then
Button.ImageTransparency = 0
print("SHOWING IT OMGGGGGGGGGGG")
else
Button.ImageTransparency = 1
end
end
function WriteToDatastore(Toggled, Setting)
WriteDatastoreRemote:FireServer(Setting, Toggled)
end
function LoadSettings(Settings: {string})
repeat task.wait() until Players.LocalPlayer.PlayerGui:WaitForChild("MainGui"):WaitForChild("LoadingFrame"):GetAttribute("Complete")
task.wait(0.5)
print("TRIGGERING")
for _,Setting in ipairs(Settings) do
print(Frames[Setting].Button.Parent.Name)
task.spawn(function()
while true do
task.wait(2)
Frames[Setting].Triggered(Frames[Setting].Button)
end
end)
end
LoadingSettings = false
end
Frames["DisplayPing"] = {
Toggled = false,
Button = nil, -- For loading settings
Triggered = function(Button: ImageButton) -- So it doesn't write again
ToggleButton(Button, Button.Parent)
_G.Settings["DisplayPing"](Frames[Button.Parent.Name].Toggled)
if not LoadingSettings then WriteToDatastore(Frames[Button.Parent.Name].Toggled, Button.Parent.Name) end
end,
}
Frames["DisplayFPS"] = {
Toggled = false,
Button = nil,
Triggered = function(Button: ImageButton)
ToggleButton(Button, Button.Parent)
_G.Settings["DisplayFPS"](Frames[Button.Parent.Name].Toggled)
if not LoadingSettings then WriteToDatastore(Frames[Button.Parent.Name].Toggled, Button.Parent.Name) end
end,
}
Frames["LowGraphics"] = {
Toggled = false,
Button = nil,
Triggered = function(Button: ImageButton)
ToggleButton(Button, Button.Parent)
_G.Settings["LowGraphics"](Frames[Button.Parent.Name].Toggled)
if not LoadingSettings then WriteToDatastore(Frames[Button.Parent.Name].Toggled, Button.Parent.Name) end
end,
}
for _,v in pairs(ScrollingFrame:GetChildren()) do
if not v:IsA("Frame") then continue end
local FrameTable = Frames[v.Name]
FrameTable.Button = v.SelectButton
v.SelectButton.MouseButton1Click:Connect(function()
FrameTable.Triggered(FrameTable.Button)
end)
end
SettingsLoadedRemote.OnClientEvent:Connect(LoadSettings)