For some reason none of my datastores have been saving on roblox.
My datastore code is not saving but it’s not saying any errors.
local dataStoreService = game:GetService("DataStoreService")
local players = game:GetService("Players")
local mainStore = dataStoreService:GetDataStore("MainDataStore")
players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Subscribers = Instance.new("IntValue")
Subscribers.Name = "Subscribers"
Subscribers.Parent = leaderstats
local success,data = pcall(function()
return mainStore:GetAsync(player.UserId)
end)
if success then
Subscribers.Value = data
else
print("Failed to load data")
end
end)
players.PlayerRemoving:Connect(function(player)
local leaderstats = player:WaitForChild("leaderstats")
local Subscribers = leaderstats:WaitForChild("Subscribers")
local success,err = pcall(function()
return mainStore:SetAsync(player.UserId, Subscribers.Value)
end)
if not success then
print(err)
end
end)
I can see why it doesn’t get written down. You load data when a player joins the game, but you don’t save data when they leave the game. So if there is no data to load from a previous session, it won’t do it.
And make sure, API Services is turned on
I can help you with create good datastore, or i can send you ready profileservice datastore
I will try to find my ds system and send it to you. If you only want to store two values, the datastore does not need to be advanced. And just in case, I can send you profliservice. I think 5 minutes max and I’ll have it.