BoolPrefs Problem

Hello evryone

i was searching for boolean player prefs for 2 days and i just dont understand it they say you should make something like this
using UnityEngine;
using System.Collections;

public class PlayerPrefs2
{
    public static void SetBool(string key, bool state)
    {
        PlayerPrefs.SetInt(key, state ? 1 : 0);
    }
 
    public static bool GetBool(string key)
    {
        int value = PlayerPrefs.GetInt(key);
 
        if (value == 1)
        {
            return true;
        }
 
        else
        {
            return false;
        }
    }
}

but there are 2 problems first of all i dont use c# and second i just dont get it i have a coin which the player has to collect and then it shouldnt appear again but i doesnt work i tried everything

if someone could explain me how to do that it would be awesome

thanks in advance skullbeats1

Maybe you should try this:

using UnityEngine;
using System.Collections;
public class Plugins : MonoBehaviour {

    public GameObject player;

	void Start(){
		if(PlayerPrefs.HasKey ("ShowCoin") && PlayerPrefs.GetString("ShowCoin") == "false"){
			Destroy (gameObject);
		}
	}
	void OnEnterCollision(Collision other){
		if(other.gameObject == player){
			PlayerPrefs.SetString("ShowCoin", "false");
			Destroy(gameObject);
		}
	}
}

And don’t forget to pull the player gameobject into the “player” property in the inspector.

BoolPrefs. Has Unityscript and C# versions.