I’m trying to make another IntValue to put into my Leaderstats but my Datastore has GetOrderedDataStore(It only save 1 value). Is it possible to Get the Value from GetOrderedDataStore and put it to GetDataStore?
--// Services
local Players = game:GetService("Players")
local DSS = game:GetService("DataStoreService")
local DataStore = DSS:GetOrderedDataStore("itzMehPlayin_Wins1") -- HERE
--// Functions
local function OnPlayerAdded(player)
local plr_key = "id_"..player.UserId.."_Wins"
local success, data = pcall(function()
return DataStore:GetAsync(plr_key)
end)
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent = player
local wins = Instance.new("IntValue")
wins.Name = "Wins"
wins.Parent = stats
print(success, data)
if success then
wins.Value = data or 0
end
end
local function OnServerShutdown()
for _, player in pairs(game:GetService("Players"):GetPlayers()) do
local plr_key = "id_"..player.UserId.."_Wins"
local wins = player.leaderstats.Wins
local success, result = pcall(function()
DataStore:SetAsync(plr_key, wins.Value)
end)
if not success then
warn(result)
end
end
end
local function OnPlayerRemoving(player)
local plr_key = "id_"..player.UserId.."_Wins"
local wins = player.leaderstats.Wins
local success, result = pcall(function()
DataStore:SetAsync(plr_key, wins.Value)
end)
if not success then
warn(result)
end
end
--// Connections
game.Players.PlayerAdded:Connect(OnPlayerAdded)
Players.PlayerRemoving:Connect(OnPlayerRemoving)
game:BindToClose(OnServerShutdown)