The item giver script with limit does not work

Good day
I need help with the item giver script with a limit (if the player does not have more than 2 items, he will give the item.)
otherwise it will give him nothing.
Here’s what I’ve created so far:

  script.Parent.ProximityPrompt.Triggered:Connect(function(player) print(player)
 for i, Tool in pairs(player.Backpack:GetChildren()) do  print(Tool) print(i)
	        if not i > 3 then print("cangive")
		local item = game.ServerStorage.Tool1:Clone() print("clone")
		item.Parent = player.Backpack  print("parentback")
	end print("end")

Problem: Script detects only one tool (I tested it with two tools)
when print (Tool) writes me one of the tools and print (i) writes me 1
And then it writes the error: Workspace.Part.Script: 5: attempt to compare boolean <number

I can’t handle it, I searched for posts but I didn’t find anything

It should be added that if I did it the other way (if i <2 then) it will give me an item in any case
and if i <3 then give me two items.
I will be happy for any help

1 Like
local ss = game:GetService("ServerStorage")
local tool1 = ss.Tool1
local part = script.Parent
local prompt = part.ProximityPrompt

	local backpack = player.Backpack
	if #backpack:GetChildren() <= 2 then
		local tool1Clone = tool1:Clone()
		tool1Clone.Parent = backpack
1 Like