Giving in game currency for joining a group problem

Hi! So I have a script which is giving people that join a group in-game currency called “cash” only once. The script is working but only if the player did not play the game before. Like, if he join the group and then plays the game, he gets $10k, but if he play the game, then leaves and then joins the group and comes back, he is not getting it. I belive it has something to do with datastore but I’m not sure. The game is autosaving.

This is in the script that is giving money:

			local money = 0
			local success,err = pcall(function()
				if player:IsInGroup(SaveSettings.giveCashToPlayersInGroup.groupId) then
					local plrCash = playerMoney:FindFirstChild(player.Name)
					if plrCash then
						plrCash.Value = plrCash.Value + SaveSettings.giveCashToPlayersInGroup.cashAmount
						money = plrCash.Value	
					end
				end
			end)

This is the “Settings” script:

			['giveCashToPlayersInGroup'] = { --Will only be given once to new players if they joined the group
			['groupId'] = 12524604, --Id of the group they must join to get cash
				['cashAmount'] = 10000  --The amount of cash they will get
			}

Do any errors appear in console?

Not really… I can’t see anything wrong

Edit: I tought about trying to make a new code but idk how to make a condition that if the player already got the money he won’t get it again

EDIT2: Or wait, I’m getting an error idk if it’s from the same thing thou:

 ERROR---------PlayerStatManager:getStat----------->  -  Server - PlayerStatManager:184

From this function:

function PlayerStatManager:getStat(player,statName)
	local succes,data = pcall(function() 
		local playerUserId = "Player_" .. player.UserId
		return sessionData[playerUserId][statName]
	end)
	if succes == false then
		warn("ERROR---------PlayerStatManager:getStat----------->")
		print(data)
		return nil
	else
		return data	
	end
end