Hello, I get this error when I try to change a code or whitelist of a codelock.
Here is my piece of code or I get error following:

foreach (var item in property.CodeLock)
            {
                CodeLock codeLock = BaseEntity.saveList.Where(x => x.OwnerID.ToString() == item).FirstOrDefault() as CodeLock;
                if (codeLock != null)
                {
                    codeLock.whitelistPlayers = new List<ulong>();
                    foreach (var player in property.Buying.Whitelist)
                        codeLock.whitelistPlayers.Add(Convert.ToUInt64(player.UserID));

                    codeLock.code = property.Code;
                    codeLock.SetFlag(BaseEntity.Flags.Locked, true);
                }
            }

 

This code denies the whitelist of the codelock, to add the players who are in property.Buying.Whitelist and changes its code