How can I make a setting saver system

Hello!

I was trying to make a setting saver with data store but i can’t do it anyway. Because when i changed a value from client, the data store service doesn’t saves it and when i changed from server, it updates for all players (When a player updated a setting that setting also updated to all players.). How can i solve that?

We can’t solve a problem without the code causing the problem. :wink:

1 Like

There is no errors at the code.

The code is like

local settingetc = player.Settings.settingetc

local settingetcopen = true

script.Parent.MouseButton1Click:ConnectFunction()
       if settingetcopen == true then
             settingetc.Value = false
             settingetcopen = false
       else
             settingetc.Value = true
             settingetcopen = true
       end
end)

like i said, when i run this with a localscript it doesn’t updates the data store service so i can’t get what i want

and when i run this with a server side script it updates every players setting.

i’m a builder and i only have some knowledge for scripts so sorry for my begginer made script.

1 Like

Could we get all of the scripts, or is it just the one you showed here?

1 Like

sure,

local players = game:GetService("Players")
local player = script.Parent.Parent.Parent.Parent

local GameSettings = script.Parent.Parent.settings

local bg_noice = player.GameSettings.bg_noice.Value
local tree_count = player.GameSettings.treecount.Value
local lbshown = player.GameSettings.levelbar.Value
local statsshown = player.GameSettings.stats.Value
local daynight = player.GameSettings.daynight.Value

local scrolling = script.Parent.ScrollingFrame

local bg = scrolling.bg_noice.buton
local tc = scrolling.tree_count.buton
local lb = scrolling.level_bar.buton
local ss = scrolling.showstats.buton
local dn = scrolling.daynight.buton


local wind = game:GetService("Workspace").Map.interactivestuff.wind:FindFirstChild("wind")

if bg_noice == true then
	wind.Playing = true
	bg.BackgroundColor3 = Color3.fromRGB(64, 252, 59)
	bg.TextLabel.Text = "AÇIK"
else
	wind.Playing = false
	bg.BackgroundColor3 = Color3.fromRGB(252, 59, 59)
	bg.TextLabel.Text = "KAPALI"
end

bg.MouseButton1Click:Connect(function()
	if bg_noice == true then
		bg_noice = false
		wind.Playing = false
		bg.BackgroundColor3 = Color3.fromRGB(252, 59, 59)
		bg.TextLabel.Text = "KAPALI"
	else
		bg_noice = true
		wind.Playing = true
		bg.BackgroundColor3 = Color3.fromRGB(64,252,59)
		bg.TextLabel.Text = "AÇIK"
	end
	bg.Position = UDim2.new(0.81,0,0.5,2)
	wait(.1)
	bg.Position = UDim2.new(0.81,0,0.5,0)
end)

bg.MouseEnter:Connect(function()
	bg:TweenSize(UDim2.new(0.23,2,1,2),Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,.1)
end)
bg.MouseLeave:Connect(function()
	bg:TweenSize(UDim2.new(0.23,0,1,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,.1)
end)

local extra = game:GetService("ReplicatedStorage").modelstorage.extra

if tree_count == true then
	if game:GetService("Workspace").Map.terrain.trees:FindFirstChild("extra") then
		game:GetService("Workspace").Map.terrain.trees:FindFirstChild("extra"):Destroy()
	end
	tc.TextLabel.Text = "AZ"
elseif tree_count == false then
	if not game:GetService("Workspace").Map.terrain.trees:FindFirstChild("extra") then
		extra:Clone().Parent = game:GetService("Workspace").Map.terrain.trees
	end
	tc.TextLabel.Text = "ÇOK"
end

tc.MouseButton1Click:Connect(function()
	if tree_count == true then
		tree_count = false
		if game:GetService("Workspace").Map.terrain.trees:FindFirstChild("extra") then
			game:GetService("Workspace").Map.terrain.trees:FindFirstChild("extra"):Destroy()
		end
		tc.TextLabel.Text = "AZ"
	else
		tree_count = true
		if not game:GetService("Workspace").Map.terrain.trees:FindFirstChild("extra") then
			extra:Clone().Parent = game:GetService("Workspace").Map.terrain.trees
		end
		tc.TextLabel.Text = "ÇOK"
	end
	tc.Position = UDim2.new(0.81,0,0.5,2)
	wait(.1)
	tc.Position = UDim2.new(0.81,0,0.5,0)
end)

tc.MouseEnter:Connect(function()
	tc:TweenSize(UDim2.new(0.23,2,1,2),Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,.1)
end)
tc.MouseLeave:Connect(function()
	tc:TweenSize(UDim2.new(0.23,0,1,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,.1)
end)

local levelbarui = script.Parent.Parent.level_ui

if lbshown == true then
	levelbarui.Visible = true
	lb.TextLabel.Text = "AÇIK"
	lb.BackgroundColor3 = Color3.fromRGB(64,252,59)
else
	levelbarui.Visible = false
	lb.TextLabel.Text = "KAPALI"
	lb.BackgroundColor3 = Color3.fromRGB(252, 59, 59)
end

lb.MouseButton1Click:Connect(function()
	if lbshown == true then
		lbshown = false
		levelbarui.Visible = false
		lb.TextLabel.Text = "KAPALI"
		lb.BackgroundColor3 = Color3.fromRGB(252, 59, 59)
	else
		lbshown = true
		levelbarui.Visible = true
		lb.TextLabel.Text = "AÇIK"
		lb.BackgroundColor3 = Color3.fromRGB(64,252,59)
	end
	lb.Position = UDim2.new(0.81,0,0.5,2)
	wait(.1)
	lb.Position = UDim2.new(0.81,0,0.5,0)
end)

lb.MouseEnter:Connect(function()
	lb:TweenSize(UDim2.new(0.23,2,1,2),Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,.1)
end)
lb.MouseLeave:Connect(function()
	lb:TweenSize(UDim2.new(0.23,0,1,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,.1)
end)

local statsui1 = script.Parent.Parent.point
local statsui2 = script.Parent.Parent.time_spended

if statsshown == true then
	statsui1.Visible = true
	statsui2.Visible = true
	ss.TextLabel.Text = "AÇIK"
	ss.BackgroundColor3 = Color3.fromRGB(64,252,59)
else
	statsui1.Visible = false
	statsui2.Visible = false
	ss.TextLabel.Text = "KAPALI"
	ss.BackgroundColor3 = Color3.fromRGB(252, 59, 59)
end

ss.MouseButton1Click:Connect(function()
	if statsshown == true then
		statsshown = false
		statsui1.Visible = false
		statsui2.Visible = false
		ss.TextLabel.Text = "KAPALI"
		ss.BackgroundColor3 = Color3.fromRGB(252, 59, 59)
	else
		statsshown = true
		statsui1.Visible = true
		statsui2.Visible = true
		ss.TextLabel.Text = "AÇIK"
		ss.BackgroundColor3 = Color3.fromRGB(64,252,59)
	end
	ss.Position = UDim2.new(0.81,0,0.5,2)
	wait(.1)
	ss.Position = UDim2.new(0.81,0,0.5,0)
end)

ss.MouseEnter:Connect(function()
	ss:TweenSize(UDim2.new(0.23,2,1,2),Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,.1)
end)
ss.MouseLeave:Connect(function()
	ss:TweenSize(UDim2.new(0.23,0,1,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,.1)
end)

local ls = game:GetService("Lighting")

local dayg = script.day
local nightg = script.night

local function deleteGradient()
	if dn:FindFirstChildWhichIsA("UIGradient") then
		dn:FindFirstChildWhichIsA("UIGradient"):Destroy()
	end
end

if daynight == true then
	ls.ClockTime = 12
	deleteGradient()
	dayg:Clone().Parent = dn
	dn.TextLabel.Text = "GÜNDÜZ"
else
	ls.ClockTime = 5
	deleteGradient()
	nightg:Clone().Parent = dn
	dn.TextLabel.Text = "GECE"
end

dn.MouseButton1Click:Connect(function()
	if daynight == true then
		daynight = false
		ls.ClockTime = 5
		deleteGradient()
		nightg:Clone().Parent = dn
		dn.TextLabel.Text = "GECE"
	else
		daynight = true
		ls.ClockTime = 12
		deleteGradient()
		dayg:Clone().Parent = dn
		dn.TextLabel.Text = "GÜNDÜZ"
	end
	dn.Position = UDim2.new(0.81,0,0.5,2)
	wait(.1)
	dn.Position = UDim2.new(0.81,0,0.5,0)
end)

dn.MouseEnter:Connect(function()
	dn:TweenSize(UDim2.new(0.23,2,1,2),Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,.1)
end)
dn.MouseLeave:Connect(function()
	dn:TweenSize(UDim2.new(0.23,0,1,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,.1)
end)

I meant the server script that handles datastore service. This doesn’t seem to do that.

Also, before we go any further, check if you have API services enabled (datastores won’t work if they aren’t):

apiservices

That seems to be what OP is doing:

local player = script.Parent.Parent.Parent.Parent
local GameSettings = script.Parent.Parent.settings

1 Like

Most games use a specialized folder that contains settings under the player name, you could use that.

i mean,

there is no issue with data store script. it works great.

also looks like the script works great tho
but when i leave the game the data doesn’t saving cause it changed from client it have to changed from server but when i made this script server sided the setting which player updated also updates other players settings.

i was asking another way to do that

(also i’m using datastore2 because when I do it with normal datastore it doesn’t save values ​​even if It changes it from server.)