Attempt to index nil with 'FindFirstChild'

local ShopGuiThing = script.Parent
local ServerStorage = game:GetService("ServerStorage")
local ServerScriptStorage = game:GetService("ServerScriptService")

local Frame = ShopGuiThing.Frame
local Container =Frame.ShopMain.ScrollingContainer
local ItemTemplate = script.Template

local ToolsFolder= ServerScriptStorage:FindFirstChild("Tools")
local toolConfig = ToolsFolder:FindFirstChild("ToolConfig")

here is the whole screen if you need


the mistake is here

why FindFirstChild is nil?
I figured I had to use require and did it but still gives the same error

1 Like

“Attempt to index nil with ‘FindFirstChild’” means that in

ToolsFolder is nil, not :FindFirstChild()


Are you requiring the modulescript from a local script? Local scripts do not have access to ServerScriptStorage

Based on the blue bar in front of the error message I think you are.

well. I am trying to require a module script from another modulescript let’s call it moduleScript2. ModuleScript2 is in a ScreenQui maybe this is a problem? ıdk
you can check the script locations or script types from explorer tap

1 Like

As long as the script that started the chain of modulescripts requiring eachother is a local script, then all of them will run on the client, thus cannot access server storage.

1 Like

so… to fix it what I have to do? if it possible I want to keep my moduleScript in ServerStorage But İf I put it the ModuleScript 2 in the serverscript how to I make it effect a PlayerGui… Man scripting is really hard

1 Like

If you want a client to use it then you have to replicate it to the client, AKA put it in ReplicatedStorage.

You can’t both hide it from the client and have the client use it at the same time.

2 Likes

I can? I mean I should be able to do it because İf I can’t put it to serverStorage or ServerScriptStorage then the game will be vulnerable against exploiters
Putting a ModuleScript to Replicated storage is really a bad idea

1 Like

The client can’t run code it doesn’t have, if you want the player to run code you have to give it to them. This has no effect on exploiters.

You only have to keep code hidden from the client that does “business logic”, basically anything that affects other players. Everything else should be done on the client.

2 Likes

what if I Reach the module by a Server script and give the code to client with a Fire event?

1 Like

That is exactly the same as putting the module in replicated storage.

3 Likes

no it is not? exploiters can see what is inside the Replicated storage so if I put the moduleScript inside the ReplicatedStorage then they can Acces Tool names,Prices etc. but if I make it with a fire event they will only see the What happens after FireClient happens So they will just know the name of module script where it is located but not the valuables inside the module script

1 Like

Variables are in the code? You are giving them the code? This would actually be less secure because roblox replicates only the bytecode (no comments), while just sending the code over will include the comments (unless you filter them out of course but that would be unnecessary extra work).

Your code is for showing items in a shop, the client must know the names, prices and etc. to be able to display them in the ui.

1 Like

image

1 Like

I think I need a coffee today. I just said that because logically, instances go in the storage…

2 Likes

Like everyone is saying, ItemHandler that is in the Gui, can’t access the ServerScriptStorage because it is a client script.

The obvious solution is to put the ToolsFolder in Replicated Storage, BUT don’t put ItemHandler in Replicated Storage because scripts can’t run in there.

Maybe something like this:

local ShopGuiThing = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Frame = ShopGuiThing.Frame
local Container = Frame.ShopMain.ScrollingContainer
local ItemTemplate = script.Template

local ToolsFolder = ReplicatedStorage:FindFirstChild("Tools")
local toolConfig = ToolsFolder:FindFirstChild("ToolConfig")
2 Likes

The client can’t acces the server storage.
Also use instead WaitForChild() is a local script, then I think that the problem is that when you use FindFirstChild, the frame has not got time enough to appear/load.
Frame:WaitForChild("Tools")