Search code examples
stringfunctionluaroblox

How do I find if the person has a card ABOVE Level _


local Part = script.Parent

Part.ProximityPrompt.Triggered:Connect(function(player)
    if not player.Backpack:FindFirstChild("Level 3 Key Card") then
        if not player.Character:FindFirstChild("Level 3 Key Card") then
            Part.Transparency = 1
        end 
    end
    if player.Backpack:FindFirstChild("Level 3 Key Card") then
        Part.Transparency = 0.7
    else
        if player.Character:FindFirstChild("Level 3 Key Card") then
            Part.Transparency = 0.7
        end
    end
end)

this code works when a player has a level 3 keycard only, but how would i make it so it works with keycards above level 3? keycard levels go up to level 6

i have tried looking on youtube but i can't seem to find tutorials on it.


Solution

  • Make several conditions with or...

    if player.Backpack:FindFirstChild("Level 3 Key Card") or player.Backpack:FindFirstChild("Level 4 Key Card") or player.Backpack:FindFirstChild("Level 5 Key Card") or player.Backpack:FindFirstChild("Level 6 Key Card") then
    ...
    else
    ...
    end