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)