Value not increasing as I want it to (DataStore2)

Hey everyone,
So I recently learned about DataStore2 and I tried to implement it to my Roblox Game but I am very confused for some reason whenever I try to increase my currency it glitches it and increases more than it should, it started happening as soon as I added DataStore2

local KoryokuIncrementEvent = game:GetService("ReplicatedStorage"):WaitForChild("Increment").KoryokuIncrement.IncrementFromTools
local DataStore2 = require(1936396537)

KoryokuIncrementEvent.OnServerEvent:Connect(function(Player,Amount)
    local Koryoku = Player:WaitForChild("Currencies").Koryoku
    print(Amount)
    local KoryokuDataStore = DataStore2("Koryoku",Player)
end)

I printed the amount and it prints 1 but increases by 94.
Help would be appreciated!

I am not sure if this is a bug or am I doing something wrong.

The free model is outdated, many issues are present in it. Get a copy from the GitHub instead:

Isn’t there a asset id that I can require or do I need to download it

You will need to download the module.

Just download it and if needed use Libraries+ for any more customization beyond the limits of the DataStore2 Library

I do not believe my module is related to this, and even then that one is outdated, use the sequel instead ;p

Are u sure that by downloading an updated version and requiring that will not affect any data saved because I have data saved of a lot of players.

The keys don’t change, so nothing will happen

3 Likes

I downloaded it so now do I replace

local DataStore2 = require(1936396537)

with

local DataStore2 = require(game.ServerScriptService.DataStore2)
1 Like

I really appreciate the help but that didn’t work instead I created a Variable and added the amount to current currency then I used :Set() to set the DataStore to Variable like this:

local KoryokuIncrementEvent = game:GetService("ReplicatedStorage"):WaitForChild("Increment").KoryokuIncrement.IncrementFromTools

local DataStore2Module = game:GetService("ServerScriptService"):WaitForChild("DataStore2")
local DataStore2 = require(DataStore2Module)

KoryokuIncrementEvent.OnServerEvent:Connect(function(Player,Amount)

	local Koryoku = Player:WaitForChild("Currencies").Koryoku
	local KoryokuDataStore = DataStore2("Koryoku",Player)
	
	local SetAmount = Koryoku.Value + Amount
	
	KoryokuDataStore:Set(SetAmount)

end)

2 Likes

It was kind of an extra thing I found, not necessary like I said but thanks that probably helps him more

1 Like