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

How Do I Fix This? "attempt to index nil with 'FindFirstChild'"

so ive been getting an error saying: (Ignore The Brackets) (attempt to index nil with 'FindFirstChild')

the full error:

(17:11:57.662 - Players.Rgboffical_yt.PlayerGui.ScreenGui.Frame.Blue.LocalScript:2: attempt to index nil with 'FindFirstChild')

the portion of the code:

local tools = game.ServerStorage:findFirstChild("DataStoreFolder")
local SpeedCoil = tools:FindFirstChild("Ak-47")
print("Done!!!!!!!!!!!")

so how do i fix it please help!!! ThankYou!!!

1 comment

0

FindFirstChild. not findFirstChild. f/F

2 answers

✓ Accepted answer

Okay, so just by the error message I can see that this is a Local Script. The reason why this doesn't work is because ServerStorage can only be accessed by the Server, same goes with ServerScriptService. Local Scripts are client-sided and therefore cannot access ServerStorage. Local Scripts can access ReplicatedStorage though, so you could move the folder there instead.

1 comment

0

Ok I Will Try It Tomorrow ThankYouSoMuch!

Most likely because "DataStoreFolder" doesn't exist whenlocal tools = game.ServerStorage:findFirstChild("DataStoreFolder") ran, so tools would be nil

Try using WaitForChild instead

local tools = game.ServerStorage:WaitForChild("DataStoreFolder")

11 comments

0

The issue is he's trying to get the folder from ServerStorage with a Local Script, which obviously won't work because Local Scripts cannot access ServerStorage.

0

True I Am Using A LocalScript

0

Even if FindFirstChild did return nil, it wouldn't error.

0

If i try WaitForChild It Just Gives Me "infiniteyield" thing

0

@Rgbofficial_yt Did you read the answer I posted? Try changing the location of the folder to ReplicatedStorage since local scripts cannot access ServerStorage.

0

Yea tnx dude

0

DUDE TYSM

0

Np.

0

Yea true i searched and i saw the article about serverstorage and ronlox said "ServerStorage Cannot Be Accesed Through Local Script/s" I Will Try Putting It To Replicated Storage tommorow cuz uhhh yea "Bed"

0

@Rgbofficial_yt i literally told you to not use ServerStorage with a LocalScript on another post.. which you also responded to.

0

Im sorry dude.Really Sorry Really Really Sorry

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