Why this auto promote not work?

Hello, I need help with an automatic promotion system on our group. Is it normal that if my partner who has the gamepass joins the game does not have the rank? Normally the script checks if the player has purchased the gamepass and provides him with the role, but nothing happens, yet we have configured everything correctly. Is it possible that the problem is that the gamepass was purchased before the script?

local groupAuthToken = "Token_group"

-- Écouter les achats de gamepass
game:GetService("MarketplaceService").ProcessReceipt = function(receiptInfo)
	local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
	if player then
		local groupId = 5908239 -- Remplacez 123456 par l'ID de votre groupe Roblox
		local roleIds = {
			[10799165] = true, -- Remplacez 987654 par l'ID du gamepass qui donne le rôle
		if roleIds[receiptInfo.ProductId] then
			-- Envoyer une requête à l'API de Roblox pour obtenir l'utilisateur
			local response = syn.request({
				Url = "https://api.roblox.com/users/"..player.UserId,
				Method = "GET",
			local userData = game:GetService("HttpService"):JSONDecode(response.Body)
			-- Envoyer une requête à l'API de Roblox pour attribuer le rôle
				Url = "https://groups.roblox.com/v1/groups/"..groupId.."/users/"..userData.Id,
				Method = "PATCH",
				Headers = {
					["Content-Type"] = "application/json",
					["X-CSRF-Token"] = groupAuthToken,
				Body = game:GetService("HttpService"):JSONEncode({
					roleId = 2, -- Remplacez 123 par l'ID du rôle à attribuer

Is it possible that the problem comes from the script? He was in serverscript…
Thank for help !