How can I use SetActive to set something active when colliding with something?

I am trying to get coins that were previously picked up to reappear when the player dies after colliding with spikes which kill the player(handled by another script). Help would be appreciated, thanks in advance.

script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CoinPickup : MonoBehaviour {

    public int pointsToAdd;


    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.GetComponent<PlayerController>() == null)
            return;

        ScoreManager.AddPoints(pointsToAdd);

        gameObject.SetActive(false);

        if (other.gameObject.name == "spikes first")
            gameObject.SetActive(true);
    }


}

Right now from the look of it you’ve got this script setup on the coins themselves.

The collision for the player would make them setactive false, however…

the second if is saying if the coins collide with spikes first? If I’m reading this correct, you want that part of the script to be called from the player (more importantly checking for his collider hitting the spikes), and the gameObject set to a list (setting to active)…

Then when the player triggers set the whole list active.

Perhaps setup a tag for the coins, when triggered it makes every object with the tag setactive.

Call this in start after setting the objects to a tag you create called “Coins”

in start:
coins = GameObject.FindGameObjectsWithTag(“Coins”);

Then set the setActive to happen for all objects with such.

You can find a similar setup here. Example here.