✓ Accepted answer
Hi! I'm new here so sorry if my answer looks weird, but I think I know why it's not working.
Okay, so first, I don't think "FindPlayers" exist. I think you're trying to use "GetPlayers", but I don't think it's necessary in something like this.
Second, I think you should use "for i,v in pairs" as it completely searches through their backpack.
Here's an example :
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
for i,v in pairs(player.Backpack:GetChildren()) do
if v.Name == 'Keycard' then
print(player.Name.." has keycard!")
else
print(player.Name.." doesn't have a keycard!")
end
end
end
end)
If a player has anything named "Keycard" in their backpack, the game will print that the player has the keycard. If not, then it'll print saying the player doesn't have a keycard. You can put your own code in the prints so it can work the way you want it to.
Hope this helps! :D
1 comment
Another idea (I'm not a very script changing person) is you could use GetChildren and limit it to one (not for multiple KEYCARDS)