Hello, I have a function the records the amount of matches you win, both for the session and for your total. For some reason, the function gets called exactly nine times, no more no less. I only define the function once. I even added a debounce to the function in the if statement. Even with the debounce, the game pauses all scripts, until it is done with adding exactly nine wins.

Here is the debounce added to the function...

function awardwin(player)
	if player ~= nil and statdebounce == false then
	statdebounce = true
		local leaderstats = player:FindFirstChild("leaderstats")
		local mydata = playerdata[player.userId]
		if leaderstats ~= nil and mydata ~= nil then
			mydata.totalwins = mydata.totalwins + 1
			local totalwinsvalue = player:FindFirstChild("Total Wins")
			local winsvalue = leaderstats:FindFirstChild("Wins")
			if totalwinsvalue ~= nil and winsvalue ~= nil then
				totalwinsvalue.Value = mydata.totalwins
				winsvalue.Value = winsvalue.Value + 1
				wait(1.2)
				statdebounce = false
			end
		end
	end
end

Basically, at the very top of the script, I defined debounce as false, when the function gets called, it defines it's self as true, runs the function and then waits 1.2 seconds before setting it's self back to false. However instead of this working, it adds one win, waits 1.2 seconds then adds another until it reaches nine.

The only other idea I have is to change the wait to a delay.

Here is where the win is being called.

	for _, player in pairs(players) do
		if player ~= nil then
			if matchresults == "KillerWins" and player == killer then
				awardskillpoints(player, 2)
				awardwin(player)
				awardxp(player, 100)
			elseif matchresults == "CiviliansWin" and player ~= killer and player ~= officer and player ~= subofficer then
				awardskillpoints(player, 4)
				awardwin(player)
				awardxp(player, 100)
			elseif matchresults == "OfficerWins" and player == officer then
				awardskillpoints(player, 4)
				awardwin(player)
				awardxp(player, 100)
			elseif matchresults == "SuvOfficerWins" and player == subofficer then
				awardskillpoints(player, 5)
				awardwin(player)
				awardxp(player, 100)
			elseif player == killer or player == officer or player == civilian or player == subofficer then
				awardxp(player, 50)
			else
				awardskillpoints(player, 0)
			end
		end
	end
end

As you can see the function only gets called once for each if statement. No where else if this function called.

Any help would be great since this makes no sense. I am testing in a server in the editor mode with three players. The function only gets called for one player since the player is given a role such as officer,killer,civilian.

The only conclusion I came up with is its a debounce even though I'm not sure why it would.

Thank you in advance.