Hey all, I’m trying to make a metal detector that gets the player’s backpack and checks for something that identifies an unauthorized tool.
However, when I fire the function, the console returns this:
(tree stuff): attempt to index nil with ‘Backpack’
This is the code I currently have that fires the error:
detector.Touched:Connect(function(Touched)
for i,v in pairs(game:GetService("Players"):GetPlayerFromCharacter(Touched.Parent).Backpack:GetChildren()) do
if v.Name == "meat" then
-- stuff here
end
end
end)
I have already pored over old posts and Developer Hub articles, and haven’t found anything to help yet. I have also tried using variables to the same if not worse effect.
I’m a brand new, straight out of the boat scripter, so any help would be appreciated. Thank you!