local Datastore = game:GetService("DataStoreService"):GetDataStore("Sofian-Datastore")
game.Players.PlayerAdded:Connect(function(player)
local Key = "Player-ID:" .. player.userId
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Coins = Instance.new("NumberValue", leaderstats)
Coins.Name = "Coins"
Coins.Value = 0
local Rebirths = Instance.new("NumberValue", leaderstats)
Rebirths.Name = "Rebirths"
Rebirths.Value = 0
local Power = Instance.new("NumberValue", leaderstats)
Power.Name = "Power"
Power.Value = 0
-- GetAsync
local GetSave = Datastore:GetAsync(Key)
if GetSave then
Coins.Value = GetSave[1]
Rebirths.Value = GetSave[2]
Power.Value = GetSave[3]
print("Data loaded for " .. player.Name)
else
local Numbers = {Coins.Value, Rebirths.Value}
Datastore:SetAsync(Key, Numbers)
print("Data Saved for " .. player.Name)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local Key = "Player-ID:" .. player.userId
local ValuesToSave = {player.leaderstats.Coins.Value, player.leaderstats.Rebirths.Value}
Datastore:SetAsync(Key, ValuesToSave)
print("Data Saved for " .. player.Name)
end)
this script prints in my studio output i enabeld api services but it still doesnt work

2 comments
Are you sure that you enabled in the game's page? If so and it still doesn't work, try and reload studio!
I suggest using int values instead of number values