How would I make function able to fire multiple times at once?

I have this code where if a prompt is triggered, it will award the player one win which will go to their leaderstats. After some testing, I’ve come to realize that if multiple people coincidentally trigger the prompt at the exact same time, it only awards one random player who triggered it and nobody else gets a win. Is there a way I can just make the function that awards points fire whenever a player triggers it at any time instead firing only when the function is complete?

Code:

prompt.Triggered:Connect(function(player)
		if not debounce then 
			debounce = true
			local winval = player.leaderstats:FindFirstChild("Wins")
			if multiply == true then
				winval.Value = winval.Value + 2
			else
				winval.Value = winval.Value + 1
			end
			wait()
			debounce = false
		end
	end)

I can send the entire code if needed but I’ve pasted the only necessary part.

1 Like

Instead of a normal debounce try using the table debounce technique to make it per player and not shared for all players.

1 Like

Ok so trying this out, it solves the overlapping thing. However, it sparks a new issue. Basically, I have a gamepass for this which doubles the amount of wins when pressed. When a player that doesn’t own the gamepass presses it, it goes up by 1. However, when a player who owns the gamepass joins the server. The player without the gamepass somehow inherits the multiplier and also starts earning 2x the points despite not owning gamepass.

1 Like
for CurrentAmount = 0, AmountOfTime, -1 do
   -- do thingy
   task.wait(1)
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.