I have two script which saves data and I've been told that I can not save multiple datas. How do I put them together then?
script one
local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("CompleteSaveSystem")
local ds2 = datastore:GetDataStore("TTSaveSystem")
game.Players.PlayerAdded:connect(function(plr)
local folder = Instance.new("Folder", plr)
folder.Name = "leaderstats"
local Complete = Instance.new("IntValue", folder)
Complete.Name = "Completes"
local TT = Instance.new("IntValue", folder)
TT.Name = "Tree Tokens"
Complete.Value = ds1:GetAsync(plr.UserId) or 0
ds1:SetAsync(plr.UserId, Complete.Value)
TT.Value = ds2:GetAsync(plr.UserId) or 0
ds2:SetAsync(plr.UserId, TT.Value)
Complete.Changed:connect(function()
ds1:SetAsync(plr.UserId, Complete.Value)
end)
TT.Changed:connect(function()
ds2:SetAsync(plr.UserId, TT.Value)
end)
end)
second:
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService") -- Getting data store service
Players.PlayerAdded:connect(function(player)
local TrackersData = DataStoreService:GetDataStore(player.UserId.."Trackers") -- Getting data store
local LevelTracker = Instance.new("Folder")
LevelTracker.Parent = player
LevelTracker.Name = "LevelTracker"
local Level1 = Instance.new("BoolValue")
Level1.Parent = LevelTracker
Level1.Name = "Level1"
Level1.Value = false
local Value = TrackersData:GetAsync("Level1") -- Getting value from data store "TrackersData"
if Value == nil then
TrackersData:SetAsync("Level1",false) -- if value equals nothing then it'll creates it.
else
Level1.Value = Value
end
end)

2 comments
Tables is always the way to go when saving multiple values.
Why won't the second script load the datas then?