Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Datastore Saving multiple values?

Asked by 5 years ago
Edited 5 years ago

i tried to do it myself but it did not worked so i asked help in discord. and well @TwinPotatoes sent me link with this one https://scriptinghelpers.org/questions/79236/my-datastore-works-if-the-valuechanges-1by1-but-not-when-it-changes-like-1000at-a-time-how-do-i-fix#73930 well i remade it to my wantings and it does not work could i get some help?

local DsService = game:GetService("DataStoreService")

local Stats = DsService:GetDataStore("PlayerSettings")

local Players = game.Players



local DefaultData = {

["FieldOfView"] = 70,

["MenuBorderColor"] = "Blue",

}



local sessionData = {}



Players.PlayerAdded:Connect(function(plr)

local data = Stats:GetAsync(plr.UserId) or DefaultData
local PlayerSettings = Instance.new("Folder")

PlayerSettings.Parent = plr
PlayerSettings.Name = "PlayerSettings"
for key, value in pairs(data) do
local valueObject
if type(value) == "string" then
valueObject = Instance.new("StringValue")
elseif type(value) == "number" then
valueObject = Instance.new("NumberValue")
end

valueObject.Parent = PlayerSettings
valueObject.Name = key
valueObject.Value = value

end

sessionData[plr.UserId] = data

end)



Players.PlayerRemoving:Connect(function(plr)
Stats:SetAsync(plr.UserId, sessionData[plr.UserId])
end)



while true do
for _, plr in pairs(game.Players:GetPlayers()) do
Stats:SetAsync(plr.UserId, sessionData[plr.UserId])
end
wait(60)
end
0
Be specific in what's wrong. Any errors in outputs? Have you tried debugging? Twinbrotato 543 — 5y
0
there are no errors and what is debugging? User#21499 0 — 5y
0
Try adding prints near steps like saving data,creating data, updating data, etc. The more you narrow it down the easier it is to fix it. Ankur_007 290 — 5y
0
This doesnt even narrow down what they are trying to save voidofdeathfire 148 — 5y

Answer this question