I am developing a card game and I have a resource called "CardData" for each card that contains all the statistics. When I assign the CardData to a card in the game, I need to create a copy of the original resource and give it to the card, otherwise all the cards will have the same stats even though they should have different health values and so on. The data.duplicate() or data.duplicate(true) function does not work because it does not overwrite the variables. So my question is: How can I duplicate a resource whose variables I can modify later, without affecting all the other resources that share the same data?

EDIT: Solved. I just needed to add a @export in front of all my variables

Maybe not the answer you were expecting, but when I have been using Resources to similar scenario as yours, what I was doing is using the Resource as the initial setup. And duplicating all the values by hand on my destiny entity (Card in your case). Or at least the ones I am expecting to change during the life of the entity.

Like:

class_name Card
extends Node

var _health : int
var _cost : int

func setup(ini_values: CardValuesResource):
    _health = ini_values.health
    _cost = ini_values.cost

Then I can do with _health and _cost whatever I want.