You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? I have a system that saves tools in the players inventory.
-
What is the issue? I try to save the tools in the players character but just gives the error, attempt to index nil with ‘GetChildren’.
-
What solutions have you tried so far? I tried to have an else statement that would save the tools through their inventory but it still gives an error.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
game.Players.PlayerRemoving:Connect(function(player)
local char = player.Character
saveData(player)
local CameraTable = {}
for i,v in pairs(player.Backpack:GetChildren())do
table.insert(CameraTable,v.Name)
end
for i,v in pairs(char:GetChildren())do -- line where error is
if v:IsA("Tool") then
print("7")
table.insert(CameraTable,v.Name)
else
warn("Cannot find tool in player's character")
for i,v in pairs(player.Backpack:GetChildren())do
print(8)
table.insert(CameraTable,v.Name)
end
end
end
if CameraTable ~= nil then
PDs:SetAsync(player.UserId,CameraTable)
end
end)
It will work in studio however it doesn’t work in the actual game.