I want it so that when the GUI is clicked, if the player does not have a card yet, then a card will be given to the player, here's my code:
script.Parent.MouseButton1Down:Connect(function()
local cards = {100, 101, 102}
if Player.Backpack:FindFirstChild(#cards) == nil then
local Keycards = ReplicatedStorage.cards:GetChildren()
local GetKeycard = Keycards[math.random(1, #Keycards)]
game.ReplicatedStorage.KeyGiver:FireServer(GetKeycard)
end
end)
The problem is that when I click the GUI I get a card. When I click again I get another card, and so on. But I only want one card per player.
Help please?

2 comments
I basically only have three card which is listed in the table (100, 101, 102). How would I run the name of the cards, from the table?
Change the numbers to strings, so the name of the cards, then run a for loop checking to see if that card exists in the players inventory for each card.