After putting in the 2nd value (Bits) this data store just stopped working.
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("WinsBits")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Wins = Instance.new("IntValue")
Wins.Name = "Wins"
Wins.Parent = leaderstats
local Bits = Instance.new("IntValue")
Bits.Name = "Bits"
Bits.Parent = leaderstats
local playerUserId = "player_"..player.UserId
local data
local success, errormessage = pcall(function()
data = DataStore:GetAsync(playerUserId)
end)
if success then
if data then
Wins.Value = data.Wins
Bits.Value = data.Bits
end
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local playerUserId = "player_"..player.UserId
local data = {
Wins = player.leaderstats.Wins.Value;
Bits = player.leaderstats.Bits.Value
}
local success, errormessage = pcall(function()
DataStore:SetAsync(playerUserId, data)
end)
if success then
print("Data successfully saved!")
else
print("error occured")
warn(errormessage)
end
end)
Thanks in advance

1 comment
make sure you ether test this in a game, not roblox studio, or a team test