Im making a card game and i need the script that generates cards to reload when the player is out of cards. Can someone please tell me how to know if the player is out of cards and how to reload a script.
First of all what engine (if any) are you using to make your game? Unity? Unreal?
Also if it happens to be Unity (or something similar) then I would create a game manager script that detects when the player is out of cards then makes a call to your card reloader script to refill the player's inventory.
I think you should not reload the script. make a function that redistributes the cards and call it when the player has 0 cards. To know the number of cards...you first need a variable that records it....maybe store it in player manager script....make a singleton game manager and add this player manager as an object to it.and call the function with an if..else under update there. I could help more if you share some screenshots of the code and your project structure
So from what I understand you have spawn points that spawn random cards from the objects array. It is not clear tho what those below 6 cards represent. So when do you call the function to spawn. And do you call a function when you play a card. Anyways, what I suggest is that make a player manager script...and do all the things like generating cards, playing cards in it...that way you can have a variable of number of cards...and change that variable whenever you play a card or draw cards.