Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why can't I access this in the folder?

So I have a folder "Character" which stores a folder called Class

This Folder Stores:

  • Other Folders
  • A string value that's called "CharacterClassName"

It's very strange that I get the error below too, because when I do a print statement above the line where I get the error, it prints it perfectly. The print statement is:

print(CharacterFolder.Class.CharacterClassName.Value) print(CharacterFolder.Class.CharacterClassName.Name)

So for some reason I am getting this error:

02:23:44.107 - CharacterClassName is not a valid member of Folder

When I write this block of code:

		-- Creates Character Folder
		local function CreateNewCharacterFolder(player, ChosenClass)
			local CharacterFolder = game.ServerStorage.Character:Clone()
			CharacterFolder.Parent = player.PlayerDataFolder
			CharacterFolder.Name = "Character "..CharacterNumberPresent
			-- The lines where I get the error are below
			CharacterFolder.Class.CharacterClassName.Name = ChosenClass
			CharacterFolder.Class.CharacterClassName.Value = ChosenClass
		end

1 answer

✓ Accepted answer

Do :WaitForChild("") On each of them, because the script might load before the objects load. Or do wait(1) in the start of the script, but the first option is better (script will work faster)

5 comments

0

Read the wiki page for :WaitForChild() if you don't understand what it is.

0

Oh I’ll try that tomorrow when I wake up. I always forget about Waiting sometimes. Hopefully it works.

0

Yeah it makes sense too since print statements are read after the code is read through.

0

Arbritrary waits are never the solution. It simply hides the problem instead of fixing the solution and may not actually fix the solution

0

This was the right solution for this scenario, only because I cloned the values right before I tried to access them.

This discussion is preserved as it was. New answers, comments, and votes are closed.