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 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)