I tried from a tip here which didn't work too idk why.. That's my code somewhy I don't have the default value like starting at lv 0
local Rep = game:GetService("ReplicatedStorage")
local DataStore2 = require(Rep:WaitForChild("MainModule"))
DataStore2.Combine("DataStoreOPM", "Level", "Points", "Exp", "MaxExp", "Strength", "Health", "Agility", "Money")
-- Defaults
local DefaultLevel = 1
local DefaultMaxExp = 50
local DefaultExp = 0
local DefaultPoints = 0
local DefaultStrength = 1
local DefaultHealth = 1
local DefaultAgility = 1
local DefaultMoney = 200
game.Players.PlayerAdded:Connect(function(player)
-- Store the values
local LevelStore = DataStore2("Level",player)
local ExpStore = DataStore2("Exp",player)
local MaxExpStore = DataStore2("MaxExp", player)
local StorePoints = DataStore2("Points", player)
local StrengthStore = DataStore2("Strength",player)
local HealthStore = DataStore2("Health",player)
local AgilityStore = DataStore2("Agility",player)
local MoneyStore = DataStore2("Money",player)
-- Leaderstats
local Data = Instance.new("Folder", player)
Data.Name = "Data"
local Level = Instance.new("IntValue", Data)
Level.Name = "Level"
local Exp = Instance.new("IntValue", Data)
Exp.Name = "Exp"
local MaxExp = Instance.new("IntValue", Data)
MaxExp.Name = "MaxExp"
MaxExp.Value = (player.Data.Level.Value + 1 ) * 1.25 *( 50)
local Points = Instance.new("IntValue", Data)
Points.Name = "Points"
local Strength = Instance.new("IntValue", Data)
Strength.Name = "Strength"
local Health = Instance.new("IntValue", Data)
Health.Name = "Health"
local Agility = Instance.new("IntValue", Data)
Agility.Name = "Agility"
local Money = Instance.new("IntValue", Data)
Money.Name = "Money"
print("OnGoing")
if player.Data.Level.Value < DefaultLevel then
print("Test")
LevelStore:Get(DefaultLevel)
print("Yes")
wait(2)
end
-- Update Functions
local function UpdateLevel(GetData)
Level.Value = LevelStore:Get(DefaultLevel)
end
local function UpdateExp(GetData)
Exp.Value = ExpStore:Get(DefaultExp)
end
local function UpdateMaxExp(GetData)
MaxExp.Value = MaxExpStore:Get(DefaultMaxExp)
end
local function UpdatePoints(GetData)
Points.Value = StorePoints:Get(DefaultPoints)
end
local function UpdateStrength(GetData)
Strength.Value = StrengthStore:Get(DefaultStrength)
end
local function UpdateHealth(GetData)
Health.Value = HealthStore:Get(DefaultHealth)
end
local function AgilityUpdate(GetData)
Agility.Value = AgilityStore:Get(DefaultAgility)
end
local function MoneyUpdate(GetData)
Money.Value = MoneyStore:Get(DefaultMoney)
end
-- Setting the functions here
UpdateExp()
UpdateHealth()
UpdateLevel()
UpdateMaxExp()
UpdatePoints()
UpdateStrength()
AgilityUpdate()
MoneyUpdate()
-- If the data update then save it
ExpStore:OnUpdate(UpdateExp)
HealthStore:OnUpdate(UpdateHealth)
LevelStore:OnUpdate(UpdateLevel)
StorePoints:OnUpdate(UpdatePoints)
StrengthStore:OnUpdate(UpdateStrength)
MoneyStore:OnUpdate(MoneyUpdate)
AgilityStore:OnUpdate(AgilityUpdate)
MaxExpStore:OnUpdate(UpdateMaxExp)
end)
