Variables.Saved.Get

using UnityEngine.Purchasing;
using UnityEngine;
using Unity.VisualScripting;

[IncludeInSettings(true)]

public class IAPCodes : MonoBehaviour
{
public static int sonuc;
public static int coins;
public static void Tata()
{

Debug.Log(Variables.Saved.Get(“Coins”));
//Up line is working !!!
// But but down line don not work… What am I doing wrong???
coins = (int)Variables.Saved.Get(“Coins”);
}

public string Onaltin = “com.www.bbb.10coin”;
public string Ellialtin = “com.www.bbb.50coin”;
public string Yuzaltin = “com.www.bbb.100coin”;

public void OnPurchaseComplete(UnityEngine.Purchasing.Product product)
{

if (product.definition.id == Onaltin)
{
Debug.Log(“Purchased 100 coins!”);

}
if (product.definition.id == Ellialtin)
{
Debug.Log(“Purchased 500 coins!”);

}
if (product.definition.id == Yuzaltin)
{
Debug.Log(“Purchased 1000 coins!”);

}
}
public void OnPurchaseFailed(UnityEngine.Purchasing.Product product,PurchaseFailureReason reson)
{
Debug.Log(" nedeni ile olumsuz!");
}

}

Warning

InvalidCastException: Specified cast is not valid.
IAPCodes.Tata () (at Assets/Scripts/IAPCodes.cs:15)
IAPCodes.OnPurchaseComplete (UnityEngine.Purchasing.Product product) (at Assets/Scripts/IAPCodes.cs:39)
UnityEngine.Events.InvokableCall1[T1].Invoke (T1 args0) (at <ca496b8c93454b2f9b9924292c19379f>:0) UnityEngine.Events.UnityEvent1[T0].Invoke (T0 arg0) (at :0)
UnityEngine.Purchasing.IAPButton.ProcessPurchase (UnityEngine.Purchasing.PurchaseEventArgs e) (at

First of all it would be nice, if you would put a question or the problem in your post, that we know for what you need help for. Second, please use code tags if you post code.

I guess you need help with the cast that doesn´t work.

try it with:

coins = int.parse(Variables.Saved.Get("Coins"));

or

coins = Int32.Parse(Variables.Saved.Get("Coins"));

here you can read about the differences and pros/cons of both methods