My datastore script is working and it output [Player left, saved DATA],
but when i rejoin the game the data is not saved.
my API services is enabled, and its not in studio.
Data script:
local DataStore2 = require(game.ServerScriptService.DataStore2)
DataStore2.Combine("DATA", "Clicks", "Diamonds", "Rebirths")
game.Players.PlayerAdded:Connect(function(player)
local clicksDataStore = DataStore2("Clicks", player)
local diamondsDataStore = DataStore2("Diamonds", player)
local rebirthsDataStore = DataStore2("Rebirths", player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local clicks = Instance.new("IntValue")
clicks.Name = "Clicks"
clicks.Parent = leaderstats
local diamonds = Instance.new("IntValue")
diamonds.Name = "Diamonds"
diamonds.Parent = leaderstats
local rebirths = Instance.new("IntValue")
rebirths.Name = "Rebirths"
rebirths.Parent = leaderstats
if clicksDataStore:Get() ~= nil then
clicks.Value = clicksDataStore:Get()
else
clicks.Value = 0
end
if diamondsDataStore:Get() ~= nil then
diamonds.Value = diamondsDataStore:Get()
else
diamonds.Value = 100
end
if rebirthsDataStore:Get() ~= nil then
rebirths.Value = rebirthsDataStore:Get()
else
rebirths.Value = 0
end
clicks.Changed:Connect(function(player)
clicksDataStore:Set(clicks.Value)
end)
diamonds.Changed:Connect(function(player)
diamondsDataStore:Set(diamonds.Value)
end)
rebirths.Changed:Connect(function(player)
rebirthsDataStore:Set(rebirths.Value)
end)
end)