-- Table to keep track of collected coins

local collectedCoins = {}

local function processCoinTouch(player, coin)
	
	-- Check if the coin has already been collected
	if collectedCoins[coin] == player then
		return -- Does nothing with the coin if it didnt respawn yet
	end
	
	collectedCoins[coin] = player --Sets the Player who collected the coin
	
	PlayerData.AdjustCoins(player, COIN_VALUE)
	Remotes.CollectCoin:FireClient(player, coin, COIN_REGEN_DELAY)

	wait(COIN_REGEN_DELAY)

	-- Remove the coin from the table of collected coins once it respawns
	collectedCoins[coin] = nil
end

