The Attempt to call a nil value Problem

Alright so, I am currently trying to work on a module script that I am making myself, but I am struggling with the attempt to call a nil value right now.
I don’t see any problems at all and I don’t know how to completely fix it.
Modulescript:

-- Basically, takes all remotes that are listed on Folder.
local RemoteEffectsFolder = game.ReplicatedStorage.RemoteEffectsFolder
local DamageEffectsFolder = RemoteEffectsFolder.DamageEffectsFolder
local MoveEffectsFolder = RemoteEffectsFolder.MoveEffectsFolder
-- Location of super amazing effects!!!
local EffectsLocation = workspace.ignore
-- Services.
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")

local effects = {}

-- Damage1
function effectsDefaultDamage(Character)
	local Effect1 = game.ServerStorage.PackageFolder.EffectsFolder.VFXFolder.Sphere:Clone()
	Effect1.Parent = EffectsLocation
	Effect1.Size = Vector3.new(6,2,6)
	Effect1.CFrame = Character.Torso.CFrame * CFrame.new(math.random(0,0.2), -0.1, math.random(0,0.2)) * CFrame.Angles(math.random(-360, 360), math.random(-360, 360), math.random(-360, 360))
	Effect1.Color = Color3.fromRGB(255, 55, 55)
	Effect1.Transparency = 0.85
	Debris:AddItem(Effect1,1.5)
	
	local Info = TweenInfo.new(1.5,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out)
	local tween = TweenService:Create(Effect1,Info,{Effect1.Size + Vector3.new(2,2,2)})
	tween:Play()
end

return effects

For executing.
EffectsModule.effectsDefaultDamage(v)

1 Like

What line is sending the errors?

05:35:16.482 Players.scribblestack.Backpack.Demolish.Script:43: attempt to call a nil value - Server - Script:43
05:35:16.483 Stack Begin - Studio
05:35:16.483 Script ‘Players.scribblestack.Backpack.Demolish.Script’, Line 43 - Studio - Script:43
05:35:16.483 Stack End - Studio

The line is.

EffectsModule.effectsDefaultSlash(character)

It this the same script, there seems to be less than 43 line?

That’s the only line that gives errors currently.
There’s the screenshot of it.
image

A module works by having the functions in the table that is returned. You must put “effects.” before your function name to solve the problem. It will add it to the table so you reference it properly and don’t reference a nil value.

2 Likes

function Module.YOUR FUNCTION NAME()

end)

1 Like

I may have just missed it or you forgot to include it in the sample code you provided, but you never referenced EffectsModule in your script.

1 Like

@scribblestack Read these answers from @koyugaki @Semistare

1 Like

Also modules are written like

local Module = {}

return Module

Right… but he never indexes a module named EffectsModule. CTRL + F and type “EffectsModule.”

Could’ve been more nice if you just included the code, just saying. I really don’t mostly get what are you saying or most because that I don’t do programming talk.

EffectsModule is on ReplicatedStorage to folder called “ModulesFolder”.
local EffectsModule = require(game.ReplicatedStorage.ModulesFolder.EffectsModule)

Assuming this is calling the module script you supplied above, and you supplied the entirety of the script, then you don’t have something called effectsDefaultSlash. You do have an effectsDefaultDamage, though it’s not included in the returned effects

And is this line included in the script that’s giving you an error? The code you posted in the original post indicates you do not have it.

It’s there, I just deleted it to give it some space on the topic. My apologizes.

That’s not the error, the error is on line
EffectsModule.effectsDefaultSlash(character)

Keep in mind, effectsDefaultSlash is here, but I removed it on this topic to give some space.

That is most likely what’s causing the error. Did you define it in the module script as effects.effectsDefaultSlash?

Can you provide the source for EffectsModule?

Like, the entire of it, if that’s what are you saying?