How do you save in-game settings

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    so Im making a obby game with s]Settings.
    and my friend has finished the settings, But i’m trying to make the settings save
  2. What is the issue? Include enough details if possible!

I have finished the whole script but it does not save its not a local script btw, it still does not save I knew this by making a Gui that turns on a BoolValue and made a script that removes a part if the value is off
and still didn’t save I was thinking about the data getting stored in a module script but I don’t know because im not good at data store scripting
3. What solutions have you thought of so far?
nothing.

heres the script btw
`
local DDS = game:GetService(“DataStoreService”)
local Players = game:GetService(“Players”)

----- Global Datas -----
local Datas = {
v1 = DDS:GetDataStore(“PlayerList”),
v2 = DDS:GetDataStore(“SoundEffectVolume”),
v3 = DDS:GetDataStore(“MusicVolume”),
v4 = DDS:GetDataStore(“Alignment_Keys”),
v5 = DDS:GetDataStore(“DeathMessages”),
v6 = DDS:GetDataStore(“UiScale”),
v7 = DDS:GetDataStore(“HidePlayers”),
v8 = DDS:GetDataStore(“BLACKTOP_PLAYERLIST”),
v9 = DDS:GetDataStore(“RespawnTime”),
v10 = DDS:GetDataStore(“ShowNameTag”),
v11 = DDS:GetDataStore(“PartShadows”),
v12 = DDS:GetDataStore(“EnableReset”),
v13 = DDS:GetDataStore(“ButtonColor”)
}


Players.PlayerAdded:Connect(function(Plr)
local SettingFolder = Instance.new(“Folder”, Plr)

SettingFolder.Name = "DataSetting"

local BlacktopPlayerList = Instance.new("BoolValue",SettingFolder)
local PlayerList = Instance.new("BoolValue", SettingFolder)
local SoundEffect = Instance.new("IntValue", SettingFolder)
local MusicVolume = Instance.new("IntValue", SettingFolder)
local Alignment_Keys = Instance.new("IntValue", SettingFolder)
local DeathMessages = Instance.new("StringValue", SettingFolder) 
local UiScale = Instance.new("IntValue",SettingFolder)
local HidePlayers = Instance.new("BoolValue",SettingFolder)
local RespawnTime = Instance.new("IntValue",SettingFolder)
local ShowNameTag = Instance.new("BoolValue",SettingFolder)
local PartShadows = Instance.new("BoolValue",SettingFolder)
local EnableReset = Instance.new("BoolValue", SettingFolder)
local ButtonColor = Instance.new("StringValue",SettingFolder)


PlayerList.Name = "PlayerListEnabled"
SoundEffect.Name = "SoundEffectVolume"
MusicVolume.Name = "MusicVolume"
Alignment_Keys.Name = "Alignment_Keys"
DeathMessages.Name = "DeathMessages"
UiScale.Name = "UiScale"
HidePlayers.Name = "HidePlayers"
RespawnTime.Name = "RespawnTime"
ShowNameTag.Name = "ShowNameTag"
PartShadows.Name = "PartShadows"
EnableReset.Name = "EnableReset"
ButtonColor.Name = "Buttons"
BlacktopPlayerList.Name = "BlackTopPlayerList"
PlayerList.Value = true
SoundEffect.Value = 1
MusicVolume.Value = 1
Alignment_Keys.Value = true
DeathMessages.Value =  "Default"
UiScale.Value = 1
HidePlayers.Value = false
RespawnTime.Value = 3
ShowNameTag.Value = true
PartShadows.Value = false
EnableReset.Value = false
ButtonColor.Value = "Normal"
BlacktopPlayerList.Value = false 
--- Saved Progress

local Key = "id_"..(Plr.UserId)

local ProgList = Datas.v1:GetAsync(Key)
local SoundEffectProg = Datas.v2:GetAsync(Key)
local MusicVolumeProg = Datas.v3:GetAsync(Key)
local Aligment_KeysProg = Datas.v4:GetAsync(Key)
local DeathMessagesProg = Datas.v5:GetAsync(Key)
local UiScaleProg = Datas.v6:GetAsync(Key)
local HidePlayersProg = Datas.v7:GetAsync(Key)
local BlackTopProg = Datas.v8:GetAsync(Key)

local RespawnProg = Datas.v9:GetAsync(Key)
local ShowNameTagProg = Datas.v10:GetAsync(Key)
local PartShadowsProg = Datas.v11:GetAsync(Key)
local EnableResetProg = Datas.v12:GetAsync(Key)
local ButtonColorProg = Datas.v13:GetAsync(Key)

if ProgList then
	PlayerList.Value = ProgList
else
	Datas.v1:SetAsync(Key, PlayerList.Value)
end

if SoundEffectProg then
	SoundEffect.Value = SoundEffectProg
else
	Datas.v2:SetAsync(Key, SoundEffect.Value)
end


if MusicVolumeProg then
	MusicVolume.Value = MusicVolumeProg
else
	Datas.v3:SetAsync(Key, MusicVolume.Value)
end

if Aligment_KeysProg then
	Alignment_Keys.Value = Aligment_KeysProg
else
	Datas.v4:SetAsync(Key, Alignment_Keys.Value)
end

if DeathMessagesProg then 
	DeathMessages.Value = DeathMessagesProg
else
	Datas.v5:SetAsync(Key,DeathMessages.Value)
end
if UiScaleProg then
	UiScale.Value = UiScaleProg
else
	Datas.v6:SetAsync(Key,UiScale.Value)
	
end
if HidePlayersProg then
	HidePlayers.Value = HidePlayersProg
else
Datas.v7:SetAsync(Key,HidePlayers.Value )
end
if BlackTopProg then
	BlacktopPlayerList.Value = BlackTopProg
else
	Datas.v8:SetAsync(Key,BlacktopPlayerList.Value)
end
if RespawnProg then
	RespawnTime.Value = RespawnProg
else
	Datas.v9:SetAsync(Key,RespawnTime.Value)
end
if ShowNameTagProg then
	ShowNameTag.Value = ShowNameTagProg
else
	Datas.v10:SetAsync(Key,ShowNameTag.Value)
end
if PartShadowsProg then
	PartShadows.Value = PartShadowsProg
else
	Datas.v11:SetAsync(Key,PartShadows.Value)
end
if EnableResetProg then
	
	EnableReset.Value = EnableResetProg
else
	Datas.v12:SetAsync(Key,EnableReset.Value)
end
if ButtonColorProg then
	ButtonColor.Value = ButtonColorProg
else
	Datas.v13:SetAsync(Key,ButtonColor.Value)
end
Players.PlayerRemoving:Connect(function(Plr)
	if PlayerList and SoundEffect and MusicVolume and Alignment_Keys and DeathMessages and UiScale and  HidePlayers and BlacktopPlayerList and   RespawnTime and  ShowNameTag and PartShadows and EnableReset and ButtonColor then
				Datas.v1:SetAsync(Key, PlayerList.Value)
		Datas.v2:SetAsync(Key, SoundEffect.Value)
		Datas.v3:SetAsync(Key, MusicVolume.Value)
		Datas.v4:SetAsync(Key, Alignment_Keys.Value)
		Datas.v5:SetAsync(Key,DeathMessages.Value)
		Datas.v6:SetAsync(Key,UiScale.Value)
		Datas.v7:SetAsync(Key,HidePlayers.Value )
		Datas.v8:SetAsync(Key,BlacktopPlayerList.Value)
		Datas.v9:SetAsync(Key,RespawnTime.Value)
		Datas.v10:SetAsync(Key,ShowNameTag.Value)
		Datas.v11:SetAsync(Key,PartShadows.Value)
		Datas.v12:SetAsync(Key,EnableReset.Value)
		Datas.v13:SetAsync(Key,ButtonColor.Value)
end
end)

end)
`