Player:GetChildren() returns {}

So I am trying to make a system, but one of my great modules that should be parented to the player, is well not there apparently (Even though me looking in studio, its there), so I decided heck, lets print the children of the player! Yeah there was nothing.

So uh wth do I do??? Im so confused, its only happening today, so like whyyyy, is it cause roblox was down? WHY STUDIO WHY!

2 Likes

You shouldn’t parent stuff under the player

1 Like

Fr, you shouldn’t parent modules under the player… Also, why can’t you just put it in ReplicatedStorage?

1 Like

I put it in the player for making my life easier, since every player has their own version of the module due to how it works, so I just put it under the player, may I ask why I shouldnt parent it the the player? The more knowledge the better right?

Well… I dunno, Roblox is very weird, especially physics related stuff. Did you remember to clone it and use that instead, instead of parenting the whole module directly?

Are you doing this on server or client?

Server

Ok but uh, the module doesnt have anything physics related in it, or involving it.
And the player is the player, which it doesnt have any physics, unless we are talking about the character, but thats the character, not the player

I’m… very confused, to say the least since this isn’t very normal… Also, by “Even though me looking in studio, its there”, you mean you was looking it from the client while playing, or from the server, while playing?

Show a screenshot of the explorer with the modulescript in the player. And the code that is indexing / referencing the module inside of the player. You should also be parenting it inside of player scripts, and not the player itself.

Does StarterPlayerScripts not serve a purpose?

3 Likes

Hmm I can check on the server if you want, but it was there on the client

image_2024-09-16_193107561

Run this using the studio command bar and see if it prints.

for I, X in pairs(game:GetService("Players"):GetDescendants()) do
 if X:IsA("ModuleScript") and X.Parent:IsA("Player") then 
  print(X) 
  break 
 end  
end

That’s not how you use a module script. Put it in ReplicatedStorage and require it in a local script in StarterPlayerScripts

If you parent it to ReplicatedStorage, you can update the Modules values based on the PlayerAdded.

Use ChildAdded to know when a child has loaded.

thing is, dont need this for a local script. I mean this would possibly work, but it still doesnt explain how out of no where, doing this one thing I’ve been doing for years, just doenst work.

For what Im doing, yeah thats not gonna work, its best if every player has their own version of it cause Im doing data stuff and its complicated lol

Everyone I figured it out:

Why do they always update out of no where like this :[

Generally you shouldn’t store things under the player regardless. If you want each player to have a different copy of data, I would look into learning how _G or shared works!

It’s miles easier to have a registry of modules and player data instead of requiring it per player- something like _G.PlayerData[Name] to store all relevant data being used in that session, and cleaning it up when they leave.

Hmm I was thinking about making one big central module that stored all of the players data, but I simply couldnt figure it out, due to it not replicating to all devices, as modules are very confusing lol, and then the problem of accessing the same values via the client resulted in me using some strange methods.