Im trying to create a tool that has a ModuleScript with a boolean and when equipped, it changes the boolean from True to False, but for some reason i keep getting the error attempt to index nil with 'ModuleScript'.
--LocalScript
local Modu = require(script.Parent.Folder:WaitForChild("ModuleScript"))
local tool = script.Parent
local function ModScript()
if Modu.Bool == true then
Modu.Bool = false
print("Yeah")
else
print("Yeah, no")
end
end
tool.Equipped:Connect(ModScript)
--ModuleScript
local module = {}
module.Bool = true
return module
I don’t want to use a function in the ModuleScript, but i mostly want to use it as a value holder since ModuleScripts can be used to share values with scripts.
I mostly just want to find a way to share and change a value using a ModuleScript instead of a BoolValue.
Can you post an image of how your scripts are setup? I tested your code on my end, and everything works fine. And yes, you can use modules to hold values, so I removed my reply. I cant get it to error at all.
Modules is not a valid member of tool is what i get after changing it. the ModuleScript is directly in the Modules Folder. Tried to see if moving local tool = script.Parent above the require did something different, same error.