Tokens Multiplaying More & More Instead Of Adding After Each Round

So the issue is, the first round when I win, I get 5 tokens which is how much it should add every time, then 2nd round, it multiplies to bigger and bigger numbers! I don’t know why to be honest.

local DataService = game:GetService(“DataStoreService”)
local TokensDataStore = DataService:GetDataStore(“Tokens”)
local TokensDataService = DataService:GetDataStore(“Tokens”)

local WebHookingService = game:GetService(“HttpService”)

game.Players.PlayerAdded:Connect(function(player)
local Folder = Instance.new(“Folder”)
Folder.Name = “TokensFolder”
Folder.Parent = player

local Tokens = Instance.new("IntValue")
Tokens.Name = "Tokens"
Tokens.Parent = Folder

local TokensData

local s , e = pcall(function()
	TokensData = TokensDataStore:GetAsync(player.UserId)
end)
if s then
	Tokens.Value = TokensData
else
	warn(e)
end

end)
game.Players.PlayerRemoving:Connect(function(player)
local s , e = pcall(function()
TokensDataStore:SetAsync(player.UserId , player.TokensFolder.Tokens.Value)
end)
if s then
print(“Saved!”)
else
warn(e)
end
end)
game.ReplicatedStorage.OnTokensWinChange.OnServerEvent:Connect(function(player)
player.TokensFolder.Tokens.Value = player.TokensFolder.Tokens.Value + 5
end)
game.ReplicatedStorage.OnTokensLoseChange.OnServerEvent:Connect(function(player)
player.TokensFolder.Tokens.Value = player.TokensFolder.Tokens.Value + 2
end)

Do you reset the gifted token value (set it to 0) each time?

1 Like

Can you show the script that fires the OnTokensWinChange event?

1 Like

No, nothing resets. These are tokens to keep forever to unlock in game cosmetics. Its supposed to add.

Yes, I am going to sleep and have no access as of now. In the morning I will share that script.

Yes but I am saying you should be resetting the value of the tokens that are to be given, not the ones you have.

1 Like

How would I do that then without deleting the user’s tokens then.