Issues with detector script

my script:
local ProximityPrompt = script.Parent

local open = false
local none = 0

ProximityPrompt.Triggered:Connect(function(Player)
if Player.Backpack == none then – this line breaking the script I think
local PlayerGui = Player:WaitForChild(“PlayerGui”)
local NoGun = PlayerGui.NoGun
local Frame = NoGun.Frame
if open == false then
open = true
Frame.Visible = true

	end
end

end)

what I am trying to do is if you triggered a proximity prompt, the thing will look inside your inventory. And if there isn’t anything in the starterpack(backpack), it will show a gui. It works when I put it like:
if Player.Backpack:FindFirstChild(“GlueRemover”) == false then

but it only works after you unequip the tool and trigger the proximity prompt again.
idk what to do please help me

1 Like

if Player.Backpack == none,this indeed breaks your code. The rest of your code looks completely fine. What are you trying to do on this line?

1 Like

He/She is trying to make a code that check Player.Backpack and see the amount of tools in there.

If there is zero, then the Gui will open.
But if there is tools in the Player.Backpack, the Gui won’t open.

You need to use ipairs for this.

He could use # + GetChildren() to check how many tools there are.

For e.g:

if #Player.Backpack:GetChildren() > 0 then
--code here( has tools)
else -- doesnt have tools in his backpack
--code herd
end

1 Like