Keep Basic Leaderstats?

I have a basic leaderstat script:

game.Players.PlayerAdded:Connect(player()
local Leaderstats = Instance.new("Folder")
Leaderstats.Name = "leaderstats"
Leaderstats.Parent = player

local Value = Instance.new("IntValue")
Value.Parent = Leaderstats
Value.Value = 100
end)

Well, this is a kind similar of the leaderstats system for my game, the problem is i saw some people using another system of leaderstats, and i dont know if i should keep my system or create another. If i should then can you help me? Thanks :slight_smile:

3 Likes

Another system of leaderstats? You could be referring to the DataStore2, which is a way of storing data from the player’s stats (and leaderstats). Alternatively, you can use the Roblox DataStore, which is similar but I believe it has more flaws than the newer version.

If you’re on about making a custom leaderboard, it’s purely if you want to have more control over the design of it, as Roblox doesn’t let you directly edit the CoreGui.

If it’s neither of these that you were referring to, I apologise as I may have misinterpreted the question.

3 Likes

Well, i just saw people using “tables” or saving the values for the leaderstats in replicated storage.

Also, some people is NOT using leaderstats and keep those values as a player value.

2 Likes

Well, you have to use some kind of datastore or database to save the table data. You can store things like

Polyheximal_Data (folder) → Money (child of folder, IntValue)

For example ^. Then, you can use a Datastore to save this (most likely putting the children’s values into a dictionary and then JSON encoding it so that you can save the data)

3 Likes

hi, i created this day, a custom leaderstats sistem and a DataStore better, it have some Addons but please, don’t use the addon ‘GetValuesFronQueqe’ it will be used to make something like: a GUI to select what ur data to use, a code example:


local DataStore3 = require(4567739397)

game.Players.PlayerAdded:Connect(function(plr)
	DataStore3:CreateLeaderstats(plr)
	
	DataStore3:CreateValue('Money',10,'MoneySaveKey','Int') ; DataStore3:SetParent('Money',plr)
    DataStore3:CreateValue('XP',10,'XpSaveKey','Int') ; DataStore3:SetParent('Xp',plr)
	
	local money = DataStore3:GetObject('Money',plr)
	
    money.Value = DataStore3:GetValue('Money',plr,10)

		
	
	
	while wait(10) do
	DataStore3:Increment('Money',50,plr)
	end
	
end)

all the function:

non-addons:

1: CreateValue(ItemName,StartValue,TheSavingKey,Type) – This if not the player have in they leaderstats the item, it will clone in player’s leaderstats
2: SetParent(ItemName,plr)
3: CreateLeaderstats(plr) creates a leaderstats in the player
4: SaveValue(plr,key,name{ex: xp}, TheValueToSave{ex: 10}) – if the queqe is full, it will wait until it isn’t full
5: Increment(ItemName,valueToAd{needs to be a number},plr)
6: GetValue(name.plr,StartValue)

–// Advanced \–
1: SaveAllValues(leaderstats,plr) – It saves all the data to the saved keys
2: GetObject(ObjectName,plr)

4 Likes

Let me review this code to understand:

local DataStore3 = require(4567739397) --Code to save Data

game.Players.PlayerAdded:Connect(function(plr) --Player added
	DataStore3:CreateLeaderstats(plr) --Creates leadestats
	
	DataStore3:CreateValue('Money',10,'MoneySaveKey','Int') ; DataStore3:SetParent('Money',plr) --Creates Money stats and sets value, can i set something like this?:
--DataStore3:CreateValue('Money',10,'MoneySaveKey','Int') ;
-- DataStore3:SetParent('Money',plr) 
    DataStore3:CreateValue('XP',10,'XpSaveKey','Iny') ; DataStore3:SetParent('Xp',plr) --Xp
	
	local money = DataStore3:GetObject('Money',plr) --Gets money
	
    money.Value = DataStore3:GetValue('Money',plr,10) --Get value

		
	
	
	while wait(10) do
	DataStore3:Increment('Money',50,plr) --Increment value, how do i substract, multiply and divide?
	end
	
end)
2 Likes

it is something like: Money.Value = Money.Value + TheValue(in our case 50) and it is still in working, i worked 2 days at it and i still work at one addon and Substract will be added in this day

edit: At the Set Value means to create the IntValue named ‘Money’ in player’s leaderstats

and the code u send after, is the same thing i do but in it ; don’t make nothing

1 Like

and the addons, are:

1:AddValueToQueqe(plr,key,ValueToAd)
2:DeleteFromQueqe(plr,key,Number) – not working, i work still on it
3:GetValuesFromQueqe(plr,key) – not working, i work still on it

2 Likes

note: if u use my Custom DataStore if u don’t want to save something put at my example instead of


money.Value = DataStore3:GetValue('Money',plr,10)

put

money.Value = Ur_Value

2 Likes

Well, i have a question:

Why the value must be 10? for saving?

Also, this will work?


local DataStore3 = require(4567739397)

-------

game.Players.PlayerAdded:Connect(function(plr)

	DataStore3:CreateLeaderstats(plr)

	DataStore3:CreateValue('Money',10,'MoneySaveKey','Int') ;
        DataStore3:SetParent('Money',plr)

        DataStore3:CreateValue('Name',10,'NameSaving','String') ;
        DataStore3:SetParent('Name',plr)
	
	local money = DataStore3:GetObject('Money',plr)
        money.Value = DataStore3:GetValue('Money',plr,10)

        local name = DataStore3:GetObject('Name',plr)
        name.Value = DataStore3:GetValue('Name',plr,"Blank")

		
	
	
	while wait(10) do
	DataStore3:Increment('Money',50,plr)
	end
	
end)
2 Likes

Internally, DataStore2 just uses Roblox’s DataStoreService too; it’s not a “newer” version. People use DataStore2 because the library makes it quicker and easier to follow good practices while keeping your code clean.

Also, DataStores are just a way of saving data. Data retrieved from a DataStore doesn’t necessarily have anything to do with leaderstats, since you can have persisting data that isn’t displayed via leaderstats and per-server values in leaderstats.

4 Likes

Hi, the 10 îs If the player don’t have a save, it will be nil și it instead of nill will be 10 and i don’t know If exists ‘StringValue’

And 10 isn’t a String so u need to put “10”

2 Likes

Well, then how do i save a string value?

2 Likes

Sry my wrong, there exists ‘StringValue’

2 Likes

And no, 10 can be any thing, If it is a “Int” it will be any number, If it îs a “String” then it can be anything that starts and ends with “” or starts with tostring()

2 Likes
DataStore3:CreateValue('Name',"Blank",'NameSaving','String') ;
DataStore3:SetParent('Name',plr)

name.Value = DataStore3:GetValue('Name',plr,game.Players.LocalPlayer)

So this will work?

2 Likes

I’d never used DataStore2 before, so I was just assuming.
I know DataStores are for saving data, I was just giving an example with how you’d save the leaderstats, they’re too different things and the only relation they have is saving the stats, although that’s not their only job.

2 Likes

No, becouse game.Players.LocalPlayer becouse it will be only at Ur Client(PC) not at all Players and the Server

3 Likes

yeah, game.Players.LocalPlayer is an example.

2 Likes

Oh, yes then, at the Type u can use “Bool”, “String”,“Int”,“CFrame”,“Obiect”,“Number” and more

3 Likes