So recently I have been messing around with the DataStore2 module. I am trying to understand it, but to me it is confusing. So could someone help me out on it? All I want is to make a simple leaderstats script with multiple values.
I don’t want to have to go through all of my scripts that add/subtract leaderstats and change them to Increment() too.
Current Script
local DataStore2 = require(game.ServerScriptService.DataStore2)
local defaultValue = 1
local defaultValue2 = 0
DataStore2.Combine("money", "claps", "level", "plus", "keylvl")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder",plr)
leaderstats.Name = "leaderstats"
local Claps = Instance.new("IntValue",leaderstats)
Claps.Name = "Claps"
local totalClaps = Instance.new("IntValue",plr)
totalClaps.Name = "totalClaps"
local Level = Instance.new("IntValue",leaderstats)
Level.Name = "Level"
local Plus = Instance.new("NumberValue",plr)
Plus.Name = "Plus"
local Money = Instance.new("IntValue",leaderstats)
Money.Name = "Money"
local KeyLevel = Instance.new("IntValue",plr)
KeyLevel.Name = "KeyLevel"
local function moneyUpdate(updatedValue)
moneyStore = DataStore2("money", plr)
Money.Value = moneyStore:Get(updatedValue)
end
moneyUpdate(defaultValue2)
moneyStore:OnUpdate(moneyUpdate)
end)
If you want to just make one for me so that I can read it go here - DataStore2 Scripter
Well I don’t know why my code isn’t working in the first place. And secondly, do I have to change my previous scripts that would increase a player’s leaderstats to a system with Increment()
Someone told me I didn’t need to change any of my previous scripts that would do something like plr.leaderstasts.Points.Value = plr.leaderstasts.Points.Value + 5 (i am switching from DataStore to DataStore2)