You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I want my script to save the tool that are in a leaving player’s backpack
What is the issue? since a tool goes to a player’s character while being equipped I’ve tried to loop through the player’s character but when I tried to do so it came up with an error
plrs.PlayerRemoving:Connect(function(plr)
for i, v in pairs(plr.Backpack:GetChildren()) do
if v:IsA("Tool") then
table.insert(toolsname, v.Name)
end
end
for i, v in pairs(plr.Character:GetChildren()) do
if v:IsA("Tool") then
table.insert(toolsname, v.Name)
end
end
It came with the error "attempt to index nil with ‘GetChildren’ "
The player does not have a character when they’re leaving the game. Try detecting CharacterRemoving and save the character in a variable, and check if they are leaving the game in that event.