I have a key that u can pick up infinity and I want it where u can only have 1 in ur inventory any help
Two things to check:
Tool-based keys
- The key is in the player’s character, meaning that they are holding the key out. To check this,
FindFirstChild
the key from the character and if it’s nil, there is no key. - The key is in the player’s backpack, meaning that they are not holding the key out and it is in the backpack. To check this, get the player and check for
player.Backpack
and the sameFindFirstChild
.
Combine these statements above and use or
operator, because it could be in either. If either is true, allow the script to not give the key to the player by ending the function promptly by using return
within the if statement’s block.
Alternatively, you can try using a cache that remembers which players are holding a key and checking that list. Slightly more tedious, but probably owrkable.
1 Like