Requested module experienced an error while loading

I’m getting an error that says Requested module experienced an error while loading on the second line of this script:

local part = script.Parent
local module = require(game.ServerScriptService.ModuleScript)

part.Touched:Connect(function(hit)
	local hum = hit.Parent:FindFirstChildOfClass("Humanoid")
	if hum then
		hum.Health = 0
		module.DoFunnySoundHaha("rbxassetid://4390298761", 3, part)
		wait(0.1)
		script:Destroy()
	end
end)

And heres the module script in question:

local Module = {}

function Module.DoFunnySoundHaha(id,vol,par)
	local sound = Instance.new("Sound")
	sound.SoundId = id
	sound.Volume = vol
	sound.Parent = par
	sound:Play()
	game.Debris:AddItem(sound,sound.TimeLength)
end

That’s the only error I’m getting. Literally all the function does is play a sound. Anyone know why this is happening? I’m completely stumped.

Did you do return Module at the end?

3 Likes

You never returned the module.

local Module = {}
function Module.DoFunnySoundHaha(id,vol,par)
	local sound = Instance.new("Sound")
	sound.SoundId = id
	sound.Volume = vol
	sound.Parent = par
	sound:Play()
	game.Debris:AddItem(sound,sound.TimeLength)
end
return module
1 Like