I want my door to accept variety of tools (ex. L1, L2, L3) whether it resides in their backpack or their character.
I tried this,
function open(player) local card = player.Backpack:FindFirstChild(acceptedCards) or player.Character:FindFirstChild(acceptedCards) local other = player.Backpack:FindFirstChild(otherCards) or player.Character:FindFirstChild(otherCards) if card then (opens) elseif other then (opens but in different way so it's important) else (denied) end end end
but that only worked when acceptedCards was only one item when I want it to be multiple items which is the problem. Please help and thank you!
do you mean something like this?
if card and other then print("both") elseif card then print("only card") elseif other then print("only other") else print("denied") end
Think of and
as you read it, if this card and other card exists then blah blah blah
EDIT: You loop through the acceptedCards
table and check FindFirstChild
for each of it;
local function isAccepted(player, cards) for _, card in ipairs(cards) do if player.Character:FindFirstChild(card) or player.Backpack:FindFirstChild(card) then return true end end return false end [...] if isAccepted(player, acceptedCards) then (opens) elseif isAccepted(player, otherCards) then (opens but in different way so it's important) else (denied) end
Read about ipairs and pairs if you don't know what it is here