local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("Brick")
local ds2 = datastore:GetDataStore("Wood")
local ds3 = datastore:GetDataStore("Level")
local ds4 = datastore:GetDataStore("XP")
local ds5 = datastore:GetDataStore("MaxXP")
game.Players.PlayerAdded:connect(function(plr)
local folder = Instance.new("Folder", plr)
folder.Name = "leaderstats"
local gems = Instance.new("IntValue", folder)
gems.Name = "Wood"
local cash = Instance.new("IntValue", folder)
cash.Name = "Brick"
local lvl = Instance.new("IntValue", folder)
lvl.Name = "Level"
local xp = Instance.new("IntValue", folder)
xp.Name = "XP"
local max = Instance.new("IntValue", folder)
max.Name = "MaxXP"
if max.Value == 0 then
max.Value = 100
end
if lvl.Value == 0 then
lvl.Value = 1
end
gems.Value = ds1:GetAsync(plr.UserId) or 0
ds1:SetAsync(plr.UserId, gems.Value)
cash.Value = ds2:GetAsync(plr.UserId) or 0
ds2:SetAsync(plr.UserId, cash.Value)
lvl.Value = ds3:GetAsync(plr.UserId) or 0
ds3:SetAsync(plr.UserId, lvl.Value)
xp.Value = ds4:GetAsync(plr.UserId) or 0
ds3:SetAsync(plr.UserId, xp.Value)
max.Value = ds5:GetAsync(plr.UserId) or 0
ds5:SetAsync(plr.UserId, max.Value)
gems.Changed:connect(function()
ds1:SetAsync(plr.UserId, gems.Value)
end)
cash.Changed:connect(function()
ds2:SetAsync(plr.UserId, cash.Value)
end)
lvl.Changed:connect(function()
ds3:SetAsync(plr.UserId, lvl.Value)
end)
xp.Changed:connect(function()
ds4:SetAsync(plr.UserId, xp.Value)
end)
max.Changed:connect(function()
ds5:SetAsync(plr.UserId, max.Value)
end)
end)
wood and brick is cash and gems cos

3 comments
Errors?
no
replace folder with boolvalue