Issues starting local test server today - worked yesterday

I’m having an issue running a local test server. Just hitting play works fine.
When I run it I get this error:

[11:33:46.165 - cClientMain is not a valid member of StarterPlayerScripts]

This is the code that I am calling:
local cClientMain = require(game.StarterPlayer.StarterPlayerScripts.cClientMain)

This worked yesterday and previous days, but today it is not working and neither are my older projects which use similar code.

I noticed when I run the local test server I have 2 folders of StarterPlayerScripts and StarterCharacterScripts. One is empty and one contains the modules/scripts. So I know it can’t find it because it’s looking in the empty folder but I have no clue why these extra empty folders are created in the first place.

Please see the attached image that shows the extra folders that are placed there at run time.

Any ideas why this started? I haven’t changed anything from yesterday vs today that I can recall. I definitely did not touch my older project from months ago so I know it wasn’t anything I did in that project.

What script has this?

It’s a bit weird you try to call something from StarterPlayerScripts, because anything in there will be put into a player’s PlayerScripts.

1 Like

What script has this?

That’s called from the InitClient script in StarterPlayerScripts.
Not sure if it’s the right place for all this, however it has never been an issue before today.

Ensure that when you go and reference “cClientMain” and require it, you add a :WaitForChild(‘cClientMain’) to avoid any issue while it replicates to the player.

Good luck!

Edit: Actually more importantly: You need to correct your reference because your init script is running under the player, not under starter player scripts

This is incorrect:

local cClientMain = require(game.StarterPlayer.StarterPlayerScripts.cClientMain)

This is correct:

local cClientMain = require(script.Parent:WaitForChild('cClientMain'))

Best of luck!

Thanks for the comment, I did try that before and it didn’t work. It appears my code is referencing the empty extra folder that is created for some reason so it will never exist. I wonder if there was some sort of update to Roblox studio today.

I most likely have to figure out the proper place for this code then the WaitForChild will most likely work correctly.

Just a quick note:

StarterPlayerScripts is nothing more than a container for any scripts or assets that you want replicated under the player object (game.Players>Player>PlayerScripts).

Local Scripts run under the PlayerScripts container, not the StarterPlayerScripts container.

Think of it as a container that has its contents cloned under the player object itself in order to run.

1 Like

Oh, cool… Thanks this all makes much more sense now and with your update above to my code I think this should all work. I didn’t realize it was replicated to each player under the workspace.

Still confused as to why there are two extra folders now, but that probably doesn’t matter anymore.

Try deleting the empty ones, it shouldn’t hurt!

Glad I could be of help.

Thanks! Can’t delete them there are not two in my project, only one exists but the extra is created on runtime for some reason but only with the test server… It’s bizarre.

It could be a rogue bit of script that is doing something unexpected…I would double check to be sure.

Oh, Ok. I’ll have to look over everything I currently have. Luckily it’s a small test project right now.

Then just do require(script.Parent:WaitForChild("cClientMain"))

StarterPlayerScripts isn’t something you normally access, and definitely isn’t something you access from a script already in there.

Yep, thanks! I have it like that now. I didn’t realize the scripts were replicated to the player objects. Now it all makes a lot more sense.

1 Like

Good to know I helped!

If you don’t mind, could you mark the reply as a solution?

Many people do end up scrolling past this topic and may or may not find my information helpful. :slight_smile: