Strange error trying to loop thru a module scripts functions

  1. What do you want to achieve?
    I’m trying to loop thru a module script and call all of its functions.

  2. What is the issue?
    I get a error that doesn’t make sense.
    " ServerStorage.Mods.SpecCurseMods.SpecMods:11: attempt to call a nil value - Server - SpecMods:11"

  3. What solutions have you tried so far?
    I’ve tried looking for similar problems, but found no results.

local module = {
	
	EveryCurse = function(plr)
		
		local mod = require(script.Parent.Parent.CurseFunc)
		local modInfo = require(script.Parent.Parent.Curses)
		local folder = plr:WaitForChild("Curses")
		
		for i,v in pairs(mod) do
			if modInfo[i][1] == "EveryCurse" then continue end
			mod[1](plr) -- error here
			print(i)
			
		end
		
	end,
}
return module

Ik that the [1] should be the i but for some reason it only fires 2 functions when I do that so I’m trying to troubleshoot my script

in any case mod[1] = nil


1 Like

So its impossible to iterate thru a module scripts functions?

no, just define a function on your mod module on index 1

I have a function on index 1 already

local module = {
	
	Frozen = function(plr)
		
		specMods.TagAdd(plr, "Frozen")
		
		local event = game:GetService("ReplicatedStorage"):WaitForChild("Events").ChangeColor
		local char = plr.Character or plr.CharacterAdded:Wait()
		
		plr.CharacterAppearanceLoaded:Connect(function()
		
			for i, v in pairs(char:GetChildren()) do
				if v:IsA("MeshPart") then	
					v.Transparency = .15
					v.Anchored = true
					v.BrickColor = BrickColor.new("Cyan")
				end
			end

			if char.Humanoid:FindFirstChild("Animator") then char.Humanoid.Animator:Destroy() end
			if char:FindFirstChild("Animate") 			then char.Animate:Destroy() 		  end
			
			event:FireAllClients( game.Workspace:WaitForChild(plr.Name) )
			
		end)
		
	end
}
return module

Unless you mean something else

is that the mod module? change Frozen to [1]