ModuleScript help

So, I’m trying to pass the various Tools scripts I have (which do the same thing) to a ModelScript, but I’m getting an error:
The first is from ModuleScript, the second is from LocalScript that is trying to Require the Module:

Sem título
This is the part of the code that ModuleScript is generating an error:

local PickModule = {}

PickModule.Tool = script.Parent.Parent
PickModule.player = game.Players.LocalPlayer
PickModule.character = PickModule.player.Character or PickModule.player.CharacterAdded:Wait()
print(PickModule.character) --> Prints correctly
PickModule.ToolEquipped = false
PickModule.debounce = true
PickModule.ToolActivatedd = false

--// Folders \\--

PickModule.Animations = PickModule.Tool:WaitForChild("Animations",3)
PickModule.Remotes = PickModule.Tool:WaitForChild("Remotes",3)
PickModule.Configs = PickModule.Tool:WaitForChild("Configs",3)

--// Animations \\--

PickModule.HoldTrack = nil

--Line that the error is generated:
PickModule.PickDown = PickModule.Animations:WaitForChild("PickDown",3) 

Am I doing something wrong?

did you return the module? 30chars

With the second argument as 3, it’ll only wait for a maximum of that amount of seconds before returning nil. I’d suggest removing this unless it’s absolutely necessary.

1 Like

Yes. For some reason the module is running, I mean: I put:

print(script.Parent) -> ReplicatedStorage

I don’t know much about ModuleScript and I don’t know if it should run without being in the Script that Require it

But how will I do after that? will I have to add it manually in the LocalScript that is requing it?

You will only need to remove the second argument:

- PickModule.Animations = PickModule.Tool:WaitForChild("Animations",3)
+ PickModule.Animations = PickModule.Tool:WaitForChild("Animations")

Remove the number argument from all the WaitForChild functions, it should not be used to get things you know for sure will exist, that is things you place in the respective locations in studio.

I realized that I can’t put the variables in ModuleScript, so I leave them in LocalScript and the functions are all in Modules. I don’t know if this is the correct way to think about ModuleScripts, however this is the way I managed to solve my error.