Does anyone know any? I've been looking all day and can't find anything.
I'm looking for a user-made API.
Data Persistence
is not a reliable way of saving leaderstats, your question doesn't seem understandable. I will still explain Data Store
though.
Data Store
is a great way to save stats of players and is very easy to understand. I will first explain on how to get a player's stats because this is very important, and calling the service.
We always must define the service that we will be using.
local Datastore = game:GetService("DataStoreService")
Next we must add a on join function
local Datastore = game:GetService("DataStoreService") game.Players.PlayerAdded:connect(function(player) --The code will go here end)
Now we must create the player's stats, please note that you can change the stats to anything you want.
local Datastore = game:GetService("DataStoreService") local Values = {"Cash", "Exp"} game.Players.PlayerAdded:connect(function(player) -- local data = Instance.new("IntValue", player) --Creating leaderstats data.Name = "leaderstats" -- for _,v in pairs(Values) do --Using In Pairs local newvalue = Instance.new("IntValue", data) --Creating new IntValues newvalue.Name = v --Naming the new IntValue end -- end)
Next we should wait for the player to load.
player:WaitForChild("data")
Now we must load the player's data if they have some, and save the stats when they change.
local Datastore = game:GetService("DataStoreService") local Values = {"Cash", "Exp"} --Stats game.Players.PlayerAdded:connect(function(player) -- local data = Instance.new("IntValue", player) --Creating leaderstats data.Name = "leaderstats" -- for _,v in pairs(Values) do --Using In Pairs local newvalue = Instance.new("IntValue", data) --Creating new IntValues newvalue.Name = v --Naming the new IntValue end -- player:WaitForChild("data") -- local Data = Datastore:GetDataStore(player.Name.."Stats") for _,v in pairs(player.leaderstats:GetChildren()) do v.Value = Data:GetAsync(v.Name) --Getting the value that has been saved v.Changed:connect(function() --When one of the values change for _,i in pairs(player:FindFirstChild("leaderstats"):GetChildren()) do Data:SetAsync(i.Name, i.Value) --Save the stats end end) end -- end)
I hope that you can understand from this example, If you still don't understand then you can look at the link below.
http://wiki.roblox.com/index.php?title=Data_store
If this is considered your answer, then mark it as answered!
This is as good a place as any to start, since it seems you've not yet done much research on the subject.