So I am trying to make a card game from Roblox, my main script is set to select all 52 cards of a random deck (there are many different decks with different colors for the cards) and insert all the cards to a table, the game will give each player their amount of cards (in this case 2 for poker) and will never give out the same card twice, there is more to it than this and it has to be table-based. At the end of every round, the script must remove all the cards from the table so that they can be replaced with different cards from a different deck. i tried using a for loop and table. remove but I got an error because it expected an object and not a number. I then tried to use
for i = 1, #cardsInRound do --cards in the round as in the cards loaded from the deck cardsInRound[i] = nil end
this works just fine but the next round I get this error
16:34:50.476 - The Parent property of S8 is locked, current parent: NULL, new parent gameCards
(s8 is a card, the 9 of spades, it works with a number score system)
if it makes a difference this is the code that loads the cards, there are only two themes ATM but I plan on adding many more in the future, this code is really simple but is causing me a lot of problems
function LoadCards() if cardTheme == 0 then for i = 1, #redCards do table.insert(cardsInRound, redCards[i]) end else if cardTheme == 1 then for i = 1, #blueCards do table.insert(cardsInRound, blueCards[i]) end end end end
thanks for any help!
I figured out the problem, I made a mistake in my code where when the card was inserted it wasn't a clone, this caused the problem where once the card was set to nil and the server chose it again on another round it wasn't available