script.Parent.Triggered:Connect(function(players)
players.PlayerGui.ItemGui.Enabled = true
local gui = players.PlayerGui.ItemGui
gui.Frame.Username.Text = "None"
script.Parent.Parent.Parent.TouchPart.Touched:Connect(function(hit)
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player then
gui.Frame.Username.Text = player.Name
end
print(player)
local backpack = player.Backpack --the problem is this line
if backpack:GetChildren() then
for i,v in ipairs(backpack:GetChildren()) do
local guil = Instance.new("TextLabel")
guil.AnchorPoint = Vector2.new(0.5, 0.5)
local size = UDim2.new(0.5, 0, 0.05, 0)
guil.Size = size
guil.Name = v.Name
guil.Text = v.Name
guil.BackgroundTransparency = 1
guil.Font = Enum.Font.Gotham
guil.TextSize = 24
guil.TextWrapped = true
guil.Parent = gui.ScrollingFrame.List
end
end
end)
script.Parent.Parent.Parent.TouchPart.TouchEnded:Connect(function(hit)
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player then
gui.Frame.Username.Text = "None"
end
end)
end)
im trying to make a item scanner but it doesnt work and gave me this error any idea why and how can i fix it?

1 comment
What if the player is nil?