local Backpack = Player:WaitForChild("Backpack") local StarterGear = Player:WaitForChild("StarterGear") if ToolData ~= nil then for i, v in pairs(ToolData) do if ToolFolder:FindFirstChild(v) and Backpack:FindFirstChild(v) == nil and StarterGear:FindFirstChild(v) == nil then ToolFolder[v]:Clone().Parent = Backpack ToolFolder[v]:Clone().Parent = StarterGear end end end Player.CharacterRemoving:Connect(function(Character) Character:WaitForChild("Humanoid"):UnequipTools() end)
Some parts of the script I deleted it because it was not shown so I deleted some parts I am showing in the part where the error is
On line 6
FindFirstChild will return true or false when used in an if statement saying if it exists or not checking if it is nil will return an error and you should check if it is not StarterGear:FindFirstChild(v)
or if StarterGear:FindFirstChild(v) == false
I fixed your code below.
local Backpack = Player:WaitForChild("Backpack") local StarterGear = Player:WaitForChild("StarterGear") if ToolData ~= nil then for i, v in pairs(ToolData) do if ToolFolder:FindFirstChild(v) and not Backpack:FindFirstChild(v) and not StarterGear:FindFirstChild(v) then -- Checking if FindFirstChild(v) is nil can not be checked as it returns a bool value. ToolFolder[v]:Clone().Parent = Backpack ToolFolder[v]:Clone().Parent = StarterGear end end end Player.CharacterRemoving:Connect(function(Character) Character:WaitForChild("Humanoid"):UnequipTools() end)