Ok so i`ve got a DataStore script which has its own Stats and im wanting to add these to values into my leaderstats but ive got no clue what im doing.
I have tried to figure it out on my own but it aint working heres the script,
local Player = game.Players.LocalPlayer
game.Players.PlayerAdded:connect(function(plr)
local stats = Instance.new("BoolValue", plr)
stats.Name = "leaderstats"
local money = Instance.new("IntValue",stats)
money.Name = "Coins"
money.Value = Player.PlayerStats.Coins.Value
end)
Data store script below
local PlayerStatsDS = game:GetService("DataStoreService"):GetDataStore("Test60")
game.Players.PlayerAdded:Connect(function(NP)
local Key = "PDS-".. NP.UserId
local GetSave = PlayerStatsDS:GetAsync(Key)
local PSF = Instance.new("Folder", NP)
PSF.Name = "PlayerStats"
local StatsFolder = script.Stats
for _, S in pairs(StatsFolder:GetChildren()) do
local NS = Instance.new(S.ClassName, PSF)
NS.Name = S.Name
NS.Value = S.Value
end
if GetSave then
for n, Stat in pairs(PSF:GetChildren()) do
warn("Loaded " .. Stat.Name .. " | " .. Stat.Value .. "!")
Stat.Value = GetSave[n]
end
else
local STS = {}
for _, Stat in pairs(StatsFolder:GetChildren()) do
table.insert(STS, Stat.Value)
warn("Saving " .. Stat.Name .. " | " .. Stat.Value .. "!")
end
PlayerStatsDS:SetAsync(Key, STS)
end
end)
game.Players.PlayerRemoving:connect(function(OP)
local Key = "PDS-".. OP.UserId
local StatsFolder = OP.PlayerStats
local STS = {}
for _, Stat in pairs(StatsFolder:GetChildren()) do
table.insert(STS, Stat.Value)
warn("Player Left,Saving " .. Stat.Name .. " | " .. Stat.Value .. "!")
end
PlayerStatsDS:SetAsync(Key, STS)
end)

2 comments
Can you send the DataStore script?
Added the script now