#My data stores DO NOT WORK help!
1 messages · Page 1 of 1 (latest)
so this is my leaderstats script
local dataStoreService = game:GetService("DataStoreService")
local leaderstats = dataStoreService:GetDataStore("leaderstats")
game.Players.PlayerAdded:Connect(function(player)
local folder = Instance.new("Folder")
folder.Name = "leaderstats"
folder.Parent = player
local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Parent = folder
local data
local success, err = pcall(function()
data = leaderstats:GetAsync(player.UserId)
if not data then
data = {0}
end
end)
coins.Value = data[1]
end)
game.Players.PlayerRemoving:Connect(function(player)
local coins = player:FindFirstChild("leaderstats"):FindFirstChild("Coins")
leaderstats:SetAsync(player.UserId, {coins.Value})
end)```
i also get this every time i stop it
DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key
i also have ```
game.Players.PlayerAdded:Connect(petsModule.AddPlayer)
game.Players.PlayerRemoving:Connect(petsModule.RemovePlayer)
local module = {}
local dataStoreService = game:GetService("DataStoreService")
local leaderstats = dataStoreService:GetDataStore("leaderstats")
module.AddPlayer = function(Player: Player)
local playerFolder = Instance.new("Folder")
playerFolder.Name = "OwnedPets"
playerFolder.Parent = Player
local playerFolder2 = Instance.new("Folder")
playerFolder2.Name = "EquippedPets"
playerFolder2.Parent = Player
local configurationFolder = Instance.new("Folder")
configurationFolder.Name = "Configuration"
configurationFolder.Parent = Player
local hatchingValue = Instance.new("BoolValue")
hatchingValue.Name = "Hatching"
hatchingValue.Parent = configurationFolder
hatchingValue.Value = false
local data
local success, error = pcall(function()
data = leaderstats:GetAsync(Player.UserId)
end)
if not data or type(data) ~= "table" then
data = {}
end
data["OwnedPets"] = data["OwnedPets"] or {}
data["EquippedPets"] = data["EquippedPets"] or {}
if error then
warn(error)
end
for i, v in pairs(data["OwnedPets"]) do
local tag = Instance.new("IntValue")
tag.Name = v
tag.Parent = playerFolder
end
for i, v in pairs(data["EquippedPets"]) do
local tag = Instance.new("IntValue")
tag.Name = v
tag.Parent = playerFolder2
end
end
module.RemovePlayer = function(Player: Player)
local data = {}
local owned = {}
local equipped = {}
for i, v in pairs(Player.OwnedPets:GetChildren()) do
table.insert(owned, v.Name)
end
for i, v in pairs(Player.EquippedPets:GetChildren()) do
table.insert(equipped, v.Name)
end
data["OwnedPets"] = owned
data["EquippedPets"] = equipped
leaderstats:SetAsync(Player.UserId, data)
end
return module
so i can see the coins tab and see the folder for owned pets and equipped pets and also the info on roblox and as you can see sometimes it saves but then it doesnt other times