Problem with Double Rebirths gamepass / Проблема с геймпассом "Двойные Ребитхы (реберсты)"

Hello, developers! I have a problem with my gamepass, and i don’t know, how i can fix it. After rejoin, player’s value doubles, and it’s a big problem for other players, and me!

This problem has reported to me by friend, i didn’t wait this report, so i’m started to check script, but i don’t understand, how to fix it, so i writing here for help! I checked, and it was real (there are screenshots with doubled value and script).

Russian: Привет, разработчики! Я имею проблему с моим геймпассом, я не знаю, как я могу пофиксить. После перезахода, у игрока значение ребитхов удваивается, и это большая проблема для игроков, и для меня!

Про эту проблему я узнал от друга, я не ожидал репорта, поэтому я начал проверять скрипт, но я не понял, как это фиксить, поэтому я пишу здесь за помощью! Я проверил баг, и он оказался правдивым (также внизу есть скриншоты с доказательством и со скриптом).

Script:

game.Players.PlayerAdded:Connect(function(player)
	
	local marketservice = game:GetService("MarketplaceService")
	
	local can = true
	repeat wait() until player:FindFirstChild("leaderstats")
	local leader = player:FindFirstChild("leaderstats")
	if leader then
	repeat wait() until leader:FindFirstChild(script:WaitForChild("Currency").Value)
	local currency = leader:FindFirstChild(script:WaitForChild("Currency").Value)
		if currency then
			local folder = Instance.new("Folder",player)
			folder.Name = "2xGamepassRebirth"
			local oldrebirth = Instance.new("IntValue",folder)
			oldrebirth.Name = "Oldrebirth"
			oldrebirth.Value = currency.Value
			local give2x = Instance.new("IntValue",folder)
			give2x.Name = "Give2x"
			give2x.Value = 0
			
			currency.Changed:Connect(function()
				if marketservice:UserOwnsGamePassAsync(player.UserId, script:WaitForChild("GamepassId").Value) then
				
					
				if can == true then
					can = false
				if currency.Value > oldrebirth.Value then
				give2x.Value = currency.Value - oldrebirth.Value
			
				currency.Value = currency.Value + give2x.Value
				
				oldrebirth.Value = currency.Value
					can = true
					else
						
							oldrebirth.Value = currency.Value
							can = true
						
						
				end
					
				end
				else
					oldrebirth.Value = currency.Value
				end
			end)

Waiting answer =( Жду ответа =( 1 2 3

1 Like

This problem works with my new DataStore, but when i checked with DataStore (with a lot of warnings), this problem worked only sometimes, because DataStore is loaded. I want to change old DataStore for better work.