Im just trying to create a scanner that scans a plays inventory, and ive got most the code down, however, I believe my code is broken because it only ever clears the player, even when the player is not supposed to be clear.
script.Parent.Touched:Connect(function(hit)
local GateParentModel = script.Parent.Parent
if hit.Parent:FindFirstChild("Humanoid") then
local PartAlreadyFound = false
local Player = Players:GetPlayerFromCharacter(hit.Parent)
local Invintory = Player.Backpack
local ItemsInInvintory = Invintory:GetChildren()
for i, v in pairs(ItemsInInvintory)do
for I,V in pairs(prohibitedItems) do
if v == V then
IllegalItemFound = true
end
end
end
if IllegalItemFound then
IllegalItemVariable.Value = "true"
else
IllegalItemVariable.Value = "false"
end
end
end)
This is particularly confusing to me because I've used a similar script to this in another project, and it worked just fine there.

2 comments
Have you made a custom inventory or are you using Roblox's in-game inventory?
Im using the premade roblox inventory.