Requested module experienced an error while loading

So I have a combat script that needs to get some modules, the rest of them work but this variable which requires an module gives me an error.

This is the line with the error:
`

local HitService = require(game.ServerStorage.modules.HitService)

`

This is the code in the module:

> *> local stunHandler = require(script.StunHandlerV2)*
> *> local module = {}*
> *> *
> *> function module.Hit(hum, damage, stunner, kb, effects)*
> *> 	if effects then*
> *> 		effects()*
> *> 	end*
> *> *
> *> 	hum:TakeDamage(damage)*
> *> 	stunHandler.Stun(hum, stunner)*
> *> *
> *> 	if kb then*
> *> 		local bv = Instance.new("BodyVelocity")*
> *> 		bv.MaxForce = Vector3.new(1,1,1) * math.huge*
> *> 		bv.Velocity = kb*
> *> *
> *> 		bv.Parent = hum.RootPart*
> *> *
> *> 		game.Debris:AddItem(bv, .1)*
> *> 	end*
> *> end*
> *> *
> *> return module*

the module is in ServerStorage and it is in a floder, as well the module contains another module and 2 sounds

whats the “effects()” function? i dont see it defined anywhere
if it did exist, it would be overwritten by the paramater. are you trying to pass a function?

This kind of errors usually happens if some lines at script got syntax as invaild or not returning the module and it’s function at the end. From your case are you sure you made your syntax correct and set your varibles correct or did you gave any undefinied varibles ?

yes, the effects function is passed from another script

I think all values are passed, I’ll check rq.

This is where I pass the args:

if combo < MaxCombo then
			HitService.Hit(hum, math.random(2, 3.5), .2, rootPart.CFrame.LookVector*10, eff)
		else
			HitService.Hit(hum, math.random(2, 3.5), .2, rootPart.CFrame.LookVector*125, eff)
		end

I don’t understand, all the values look valid, if you want I’ll send you the code to see yourself because I might miss something

This is the part of the code:



function hitbox(hitBox, humanoid, rootPart, combo)
hitBox.Touched:Connect(function(hit, hum)

if hum == humanoid then return end
	
local function eff()
	local effect = ReplicatedStorage["Impact punchs effects particles"]:Clone()
	effect.Position = hit.Position
	effect.Parent = workspace

	local sound = Instance.new("Sound")
	sound.SoundId = "http://www.roblox.com/asset/?id=8595975878"
	sound.PlaybackSpeed = 1.2
	sound.Volume = .75
	sound.Parent = hit
	sound:Play()
		
	game.Debris:AddItem(effect, .45)
	game.Debris:AddItem(sound, .75)
end
	
	
coroutine.resume(coroutine.create(function()
	if combo == 2 or combo == 4 then

		local animator2 = hum.Animator
		local animation2 = Instance.new("Animation")
		animation2.AnimationId = Animations.toRight
		local track = animator2:LoadAnimation(animation2)
		track:Play()
		track:AdjustSpeed(.7)
		task.wait(.75)
		track:Stop()

	else

		local animator2 = hum.Animator
		local animation2 = Instance.new("Animation")
		animation2.AnimationId = Animations.toLeft
		local track = animator2:LoadAnimation(animation2)
		track:Play()
		track:AdjustSpeed(.85)
		task.wait(.75)
		track:Stop()	
	end
end))
	
	
	if combo < MaxCombo then
		HitService.Hit(hum, math.random(2, 3.5), .2, rootPart.CFrame.LookVector*10, eff)
	else
		HitService.Hit(hum, math.random(2, 3.5), .2, rootPart.CFrame.LookVector*125, eff)
	end
	
end)
end

does “StunHandlerV2” exist in your HitService module?

yes, it is in my module, I require it in the module from where I get the error

i’m not too sure what your issue is, but i feel obligated to mention that math.random(2,3.5) will only ever return 2 and 3. math.random() is incapable of returning decimals.

consider replacing it with Random.new():NextNumber(2,3.5)

ty even for that, I didn’t know

if this issue can not be solved I am most likely needing to just take another module, place the stunner code in that module and the rest, because it is letting me to do an module without anything in it which it isn’t in a folder

The video from where I inspired a little bit is on yt, from him I took this HitService idea, and I did the same as he, I placed the module like him, I gave the same args. but for him it worked. If ur interested you can find the video on the channel SushiMaster, the video is called combat system(REWORKED)

I see this problem is with any module, I can’ require anything anymore, just a module from RS.

this is what I tried to require:
local HitService = require(game.ServerStorage.hitModule)

I see this problem is with any module, I can’ require anything anymore, just a module from RS.

this is what I tried to require:
local HitService = require(game.ServerStorage.hitModule)