✓ Accepted answer
Hello,
You should always format your code using a code block, it makes it easier to see.
There's a few things wrong. You're most likely trying to run the script before the player's Character is loaded. You should use the same kind of for loop you used to make "tab" with printing tab, because you're only printing the number of the value of tab.
Here's how you can fix it:
local tab = {}
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
for i,v in pairs (character:GetChildren()) do
if v:IsA("Accessory") then
table.insert(tab,v.Name)
end
end
for i, v in pairs(tab) do
print(v)
end
2 comments
Your problem, is that the local script loads before the character and it's children, so it doesn't do anything. You should make it wait for the character to load before you start storing the accessories' names.
Exactly what Mineloxer said. Tell the script to wait until the players character is found. Before you run the for loop.