Why isn't my script finding my function within my module script?

I’m having a problem where when I try to call a function (not a local function) from my module script, it doesn’t find it. This is my first time using a module script though.

Relevent Code inside my serverscript:

local GladiusModule = require(game.ServerStorage:WaitForChild("GladiusModule"))

--Later in my code:
GladiusInUse.Changed:Connect(function()
	print("Gladius Module Being Called...")
	GladiusModule.equipGladius(Gladius, SheathedGladius, GladiusInUse)
end)

My entire modulescript so far:

local GladiusModule = {}

--Config Variables
local GladiusDamage = 25

--Misc
local GladiusDebounce = false
local GladiusCanDamage = true

function equipGladius(Gladius, SheathedGladius, GladiusInUse)
	if GladiusInUse.Value == false then
		for i, part in pairs(Gladius:GetChildren()) do
			if part:IsA("Part") or part:IsA("MeshPart") or part:IsA("BasePart") then
				part.Transparency = 1
			end
		end
		for i, part in pairs(SheathedGladius:GetChildren()) do
			if part:IsA("Part") or part:IsA("MeshPart") or part:IsA("BasePart") then
				part.Transparency = 0
			end
		end
	else
		for i, part in pairs(SheathedGladius:GetChildren()) do
			if part:IsA("Part") or part:IsA("MeshPart") or part:IsA("BasePart") then
				part.Transparency = 1
			end
		end
		for i, part in pairs(Gladius:GetChildren()) do
			if part:IsA("Part") or part:IsA("MeshPart") or part:IsA("BasePart") then
				part.Transparency = 0
			end
		end
	end
end

return GladiusModule

1 Like

Any error in the output?? I am also quite inexperienced with module scripts

This is the error:
22:20:11.784 Workspace.MRBOGO_YT.ToolsServer:70: attempt to call a nil value - Server - ToolsServer:70

do this

function GladiusModule.equipGladius()
1 Like

Where would I put this exactly? I.e. the module or server scripts.

In the module script replace function equipGladius() with what they said.

1 Like

oh replace the part in the module

function equipGladius(Gladius, SheathedGladius, GladiusInUse)
function GladiusModule.equipGladius(Gladius, SheathedGladius, GladiusInUse)
1 Like

Ok, thanks I couldn’t figure that out lol. Thanks for the help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.