local DS = game:GetService("DataStoreService")
local myDataStore = DS:GetDataStore("myDataStore")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder", plr)
leaderstats.Name = "leaderstats"
local Gems = Instance.new("IntValue")
Gems.Value = 0
Gems.Name = "Gems"
Gems.Parent = leaderstats
local Wins = Instance.new("IntValue")
Wins.Value = 0
Wins.Name = "Wins"
Wins.Parent = leaderstats
local playeruserid = "Player"..plr.UserId
print(playeruserid)
-- LOAD DATA
-- YEAH -- YEAH
local data
local succsess, errormessage = pcall(function()
data = myDataStore:GetAsync(playeruserid)
end)
if succsess then
if data then
Gems.Value = data.Gems
end
-- SET OUR DATA
end
game.Players.PlayerRemoving:Connect(function(player)
local playeruserid = "Player"..plr.UserId
local data = {
Gems = player.leaderstats.Gems.Value;
Wins = player.leaderstats.Wins.Value;
}
local succsess, errormessage = pcall(function()
myDataStore:SetAsync(playeruserid, data)
end)
if succsess then
print("finally")
else
print("nope you didn't wrong WARNING")
warn(errormessage)
end
end)
end)
but then i get this Workspace.DATA STORE LEADERSTATS:31: attempt to index number with 'Gems'
