I don’t know if this is a bug or if I am doing something wrong. But when I run the following code:
for i,v in pairs(game.Players.StrategicPlayZ:GetChildren()) do print(v:IsA("Accessory")) end
It prints “false” 5 times, even though there are many objects in my character, like 10-12, and also a few accessories, but it doesn’t print that too.
It is not looping through all of them.
Because you’re iterating through the
Player instance’s children. You should be iterating over the character. The
Character property of a player references their instance in
Workspace that holds their Humanoid, Hats, and equipped Gear, and everything that you would expect the player’s Character to have.
for i, v in pairs(game.Players.StrategicPlayZ.Character:GetChildren()) do
However I suggest you clean up the code a bit.
local players = game:GetService("Players")
local player = players.StrategicPlayZ
local character = player.Character
local children = character:GetChildren()
for i, child in pairs(children) do
Carrying on with what @EpicMetatableMoment said, you should probably check that the player is fully loaded as well, before you run this code.
Is there a good method for checking wheter the character of a player has fully loaded in or not?
Is a pretty good way to do just that
Edit: I thought I would add some more context
You probably want to use a repeat loop for this because it checks before it waits,
I should note there is also an event for this, which might be better in this scenario.
Right on @EpicMetaTableMoment,
I wasn’t aware of this event.
In this case you could do: