You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to make this module script work, even though it’s not clear what the problem is. I’m making a card game that my family plays but in Roblox, and I need a module script to keep track of the 2 decks of cards that the game uses so that it doesn’t give out dupes of cards. The GiveCards event should give a cards back to the deck (like when you end a hand and return all of the played cards to the deck) and the TakeCards event should take them from the deck (like drawing from the deck). -
What is the issue? Include screenshots / videos if possible!
This module doesn’t show any errors, but when I make another script require it, it says that the module has an error while loading. -
What solutions have you tried so far? Did you look for solutions on the Creator Hub?
I can’t find anything that relates to my problem. It’s in ReplicatedStorage, which should be fine, but i moved it to some other places to troubleshoot. I have tried to put the module’s code into a normal script so that an error would fire, but nothing happened. I’m thinking it’s a syntax error since it’s while loading, but I’m not sure since I looked at the whole script and couldn’t find anything.
Here’s my code:
local rs = game:GetService("ReplicatedStorage")
local Deck =
{
"AC", "AD", "AH", "AS",
"2C", "2D", "2H", "2S",
"3C", "3D", "3H", "3S",
"4C", "4D", "4H", "4S",
"5C", "5D", "5H", "5S",
"6C", "6D", "6H", "6S",
"7C", "7D", "7H", "7S",
"8C", "8D", "8H", "8S",
"9C", "9D", "9H", "9S",
"0C", "0D", "0H", "0S",
"JC", "JD", "JH", "JS",
"QC", "QD", "QH", "QS",
"KC", "KD", "KH", "KS",
"!C", "!S",
"AC", "AD", "AH", "AS",
"2C", "2D", "2H", "2S",
"3C", "3D", "3H", "3S",
"4C", "4D", "4H", "4S",
"5C", "5D", "5H", "5S",
"6C", "6D", "6H", "6S",
"7C", "7D", "7H", "7S",
"8C", "8D", "8H", "8S",
"9C", "9D", "9H", "9S",
"0C", "0D", "0H", "0S",
"JC", "JD", "JH", "JS",
"QC", "QD", "QH", "QS",
"KC", "KD", "KH", "KS",
"!C", "!S"
}
--give cards to the deck
rs.Events.GiveCards.OnServerEvent:Connect(function(plr, cards)
if typeof(cards) ~= "table" then
warn("sent a non-table value to the give cards event!")
end
for i, v in pairs(Deck) do
if not table.find(cards, v) then
table.insert(Deck, v)
print("inserted "..tostring(v))
else
print("card already in deck, card is "..tostring(v))
end
end
end)
--take cards from the deck
rs.Events.TakeCards.OnServerEvent:Connect(function(plr, cards)
if typeof(cards) ~= "table" then
warn("sent a non-table value to the take cards event!")
end
for i, v in pairs(Deck) do
if table.find(cards, v) then
table.remove(Deck, table.find(cards, v))
print("removed "..tostring(v))
else
print("card not found to remove, card is "..tostring(v))
end
end
end)
Deck.GetData = function()
return Deck
end
return Deck
If you need more info, I am willing to do anything to fix this, although I dont know if anything else is relevant.