Requested module experienced an error while loading

Hello I’m trying to make an Rng game and I got this error “Requested module experienced an error while loading” when I hover over the warning it says this:

image

the error in the output:
image

the script:

local SS = game:GetService("ServerScriptService")
local RS = game:GetService("ReplicatedStorage")

local AuraModule = require(SS.AuraHandler)

local AnimationsConfig = require(RS.AnimationsConfig)
local SoundsConfig = require(RS.SoundsConfig)

local Auras = RS.Auras
local Remotes = RS.Remotes

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local Animator = char:WaitForChild("Humanoid").Animator
		
		for name, id in pairs(AnimationsConfig) do
			local anim = Instance.new("Animation")
			anim.AnimationId = "rbxassetid://"..tostring(id)
			
			local animationTrack = Animator:LoadAnimation(anim)
		end
		
		local AurasFolder = Instance.new("Folder", char)
		AurasFolder.Name = "AURA"
		
		local AuraSound = Instance.new("Sound", char:WaitForChild("HumanoidRootPart"))
		AuraSound.Name = "AuraSound"
		AuraSound.RollOffMinDistance = 1
		AuraSound.RollOffMaxDistance = 0
		AuraSound.Looped = true
		AuraSound.Volume = 0
		AuraSound.TimePosition = 0
	end)
end)

Remotes.AuraEquip.OnServerEvent:Connect(function(player, aura)
	local char = player.Character
	
	AuraModule.EquipAura(player, char, aura)
end)

Remotes.AuraUnequipAll.OnServerEvent:Connect(function(player)
	local char = player.Character
	
	AuraModule.UnequipAll(player, char)
end)

thanks.

We need to see AuraHandler to find the issue

2 Likes

of course, sorry for the inconvenicencececec

local SS = game:GetService("ServerScriptService")
local RS = game:GetService("ReplicatedStorage")

local AnimationsConfig = require(RS.AnimationsConfig)
local SoundsConfig = require(RS.SoundsConfig)

local AuraHandler = {}
local activeAnimations = {}

local function hasAnimation(auraname)
	local animationId = AnimationsConfig[auraname]
	if animationId then
		return true, animationId
	else
		return false
	end
end

local function hasSound(auraname)
	if SoundsConfig[auraname] ~= nil then
		local soundID, volume, distance = SoundsConfig[auraname].SoundID, SoundsConfig[auraname].Volume, SoundsConfig[auraname].Distance
		if soundID and volume and distance then
			return true, soundID, volume, distance
		else
			return false
		end
	end
end


local function Animation(player,char,aura)
	local result, animationId = hasAnimation(aura.Name)
	if result then
		warn(aura.Name.." has an Animation")
		
		local humanoid = char:FindFirstChildOfClass("Humanoid")
		if not humanoid then
			warn("No humanoid found for: "..char.Name)
			return
		end
		
		local animator = humanoid:FindFirstChildOfClass("Animator")
		if not animator then
			animator.Parent = humanoid
		end
		
		local animation = Instance.new("Animation")
		animation.AnimationId = "rbxassetid://"..tostring(animationId)
		local animationTrack = animator:LoadAnimation(animation)
		animationTrack:Play()
		
		if not activeAnimations[player.UserId] then
			activeAnimations[player.UserId] = {}
		end
		activeAnimations[player.UserId] [aura.Name] = animationTrack
	else
		warn("No Animation found for: "..aura.Name)
	end
end



local function Sound(player,char,aura)
	local result, soundID, volume, distance = hasSound(aura.Name)
	if result then
		local SoundInstance = char:FindFirstChild("HumanoidRootPart"):FindFirstChild("AuraSound")
		if not SoundInstance or not SoundInstance:IsA("Sound") then return end
		
		SoundInstance.SoundId = "rbxassetid://"..soundID
		SoundInstance.RollOffMaxDistance = distance
		SoundInstance.Volume = volume
		SoundInstance.Playing = true
	end
end


function AuraHandler.EquipAura(player, char, aura)
	if not player or not char or not aura then
		warn("Missing parameters.")
		return
	end
	
	local Auras = RS:FindFirstChild("Auras")
	if not Auras then return end
	
	if not Auras:FindFirstChild(aura.Name) then
		warn(aura.Name .. " wasn't found in ReplicatedStorage!")
		return
	end
	
	local auraFolder = char:FindFirstChild("AURA")
	if not auraFolder then
		auraFolder = Instance.new("Folder", char)
		auraFolder.Name = "AURA"
	end
	
	if #auraFolder:GetChildren() > 0 then
		warn("The aura: " .. auraFolder:GetChildren()[1].Name .. " is already equipped!")
		return
	end
	
	
	local auraClone = Auras(aura.Name):Clone()
	auraClone.Parent = auraFolder

	local function cloneAndWeldParts(sourcePart,  targetpart)
		for _, part in ipairs(sourcePart:GetChildren()) do
			if part:IsA("BasePart") then
				local correspondingPart = targetpart:FindFirstChild(part.Name)
				if correspondingPart then
					local auraPartClone = part:Clone()
					auraPartClone.Parent = correspondingPart
					auraPartClone.CFrame= correspondingPart.CFrame
					local weld = Instance.new("WeldConstraint")
					weld.Part0 = correspondingPart
					weld.Part1 = auraPartClone
					weld.Parent = correspondingPart
				end
			elseif part:IsA("Model") then
				local correspondingpart = targetpart:FindFirstChild(part.name)
				if correspondingpart then
					cloneAndWeldParts(part, correspondingpart)
				end
			end
		end
	end
end

cloneAndWeldParts(auraClone, char)


if not auraFolder:FindFirstChild(aura.Name) then
	local value = Instance.new("StringValue", auraFolder)
	value.Name = aura.Name
end

Animation(player, char, {Name = aura.Name})
Sound(player, char, {Name = aura.Name})

warn(aura.Name .. " equipped to " .. char.Name)
end


function AuraHandler.UnequipAll(player,char)
	if player and char then
		local auraFolder = char:FindFirstChild("AURA")
		if auraFolder then
			local auraName = auraFolder:FindFirstChildWhichIsA("Folder")
			
			if activeAnimations[player.UserId] then
				for auraName, animationTrack in pairs(activeAnimations[player.UserId]) do
					animationTrack:Stop()
				end
				activeAnimations[player.UserId] = nil
			end
			
			local SoundInstance = char:FindFirstChild("HumanoidRootPart"):FindFirstChild("AuraSound")
			if SoundInstance then
				SoundInstance.SoundId = " "
				SoundInstance.RollOffMaxDistance = 0
				SoundInstance.Volume = 0
				SoundInstance.TimePosition = 0
			end
			
			for _, child in char:GetChildren() do
				for _, secondChild in child:GetChildren() do
					if secondChild.Name == child.Name then
						secondChild:Destroy()
					end
				end
			end
			
			warn("The aura: "..auraName.Name.."  was successfully destroyed!")
			auraName:Destroy()
		end
	end
end


return AuraHandler

also thats really funny i was just looking at your forum about this lol

1 Like

It looks like your module source is malformed due to an extra end on line 127

Fixed
local SS = game:GetService("ServerScriptService")
local RS = game:GetService("ReplicatedStorage")

local AnimationsConfig = require(RS.AnimationsConfig)
local SoundsConfig = require(RS.SoundsConfig)

local AuraHandler = {}
local activeAnimations = {}

local function hasAnimation(auraname)
	local animationId = AnimationsConfig[auraname]
	if animationId then
		return true, animationId
	else
		return false
	end
end

local function hasSound(auraname)
	if SoundsConfig[auraname] ~= nil then
		local soundID, volume, distance = SoundsConfig[auraname].SoundID, SoundsConfig[auraname].Volume, SoundsConfig[auraname].Distance
		if soundID and volume and distance then
			return true, soundID, volume, distance
		else
			return false
		end
	end
end


local function Animation(player,char,aura)
	local result, animationId = hasAnimation(aura.Name)
	if result then
		warn(aura.Name.." has an Animation")

		local humanoid = char:FindFirstChildOfClass("Humanoid")
		if not humanoid then
			warn("No humanoid found for: "..char.Name)
			return
		end

		local animator = humanoid:FindFirstChildOfClass("Animator")
		if not animator then
			animator.Parent = humanoid
		end

		local animation = Instance.new("Animation")
		animation.AnimationId = "rbxassetid://"..tostring(animationId)
		local animationTrack = animator:LoadAnimation(animation)
		animationTrack:Play()

		if not activeAnimations[player.UserId] then
			activeAnimations[player.UserId] = {}
		end
		activeAnimations[player.UserId] [aura.Name] = animationTrack
	else
		warn("No Animation found for: "..aura.Name)
	end
end



local function Sound(player,char,aura)
	local result, soundID, volume, distance = hasSound(aura.Name)
	if result then
		local SoundInstance = char:FindFirstChild("HumanoidRootPart"):FindFirstChild("AuraSound")
		if not SoundInstance or not SoundInstance:IsA("Sound") then return end

		SoundInstance.SoundId = "rbxassetid://"..soundID
		SoundInstance.RollOffMaxDistance = distance
		SoundInstance.Volume = volume
		SoundInstance.Playing = true
	end
end


function AuraHandler.EquipAura(player, char, aura)
	if not player or not char or not aura then
		warn("Missing parameters.")
		return
	end

	local Auras = RS:FindFirstChild("Auras")
	if not Auras then return end

	if not Auras:FindFirstChild(aura.Name) then
		warn(aura.Name .. " wasn't found in ReplicatedStorage!")
		return
	end

	local auraFolder = char:FindFirstChild("AURA")
	if not auraFolder then
		auraFolder = Instance.new("Folder", char)
		auraFolder.Name = "AURA"
	end

	if #auraFolder:GetChildren() > 0 then
		warn("The aura: " .. auraFolder:GetChildren()[1].Name .. " is already equipped!")
		return
	end


	local auraClone = Auras(aura.Name):Clone()
	auraClone.Parent = auraFolder

	local function cloneAndWeldParts(sourcePart,  targetpart)
		for _, part in ipairs(sourcePart:GetChildren()) do
			if part:IsA("BasePart") then
				local correspondingPart = targetpart:FindFirstChild(part.Name)
				if correspondingPart then
					local auraPartClone = part:Clone()
					auraPartClone.Parent = correspondingPart
					auraPartClone.CFrame= correspondingPart.CFrame
					local weld = Instance.new("WeldConstraint")
					weld.Part0 = correspondingPart
					weld.Part1 = auraPartClone
					weld.Parent = correspondingPart
				end
			elseif part:IsA("Model") then
				local correspondingpart = targetpart:FindFirstChild(part.name)
				if correspondingpart then
					cloneAndWeldParts(part, correspondingpart)
				end
			end
		end
	end

	cloneAndWeldParts(auraClone, char)


	if not auraFolder:FindFirstChild(aura.Name) then
		local value = Instance.new("StringValue", auraFolder)
		value.Name = aura.Name
	end

	Animation(player, char, {Name = aura.Name})
	Sound(player, char, {Name = aura.Name})

	warn(aura.Name .. " equipped to " .. char.Name)
end


function AuraHandler.UnequipAll(player,char)
	if player and char then
		local auraFolder = char:FindFirstChild("AURA")
		if auraFolder then
			local auraName = auraFolder:FindFirstChildWhichIsA("Folder")

			if activeAnimations[player.UserId] then
				for auraName, animationTrack in pairs(activeAnimations[player.UserId]) do
					animationTrack:Stop()
				end
				activeAnimations[player.UserId] = nil
			end

			local SoundInstance = char:FindFirstChild("HumanoidRootPart"):FindFirstChild("AuraSound")
			if SoundInstance then
				SoundInstance.SoundId = " "
				SoundInstance.RollOffMaxDistance = 0
				SoundInstance.Volume = 0
				SoundInstance.TimePosition = 0
			end

			for _, child in char:GetChildren() do
				for _, secondChild in child:GetChildren() do
					if secondChild.Name == child.Name then
						secondChild:Destroy()
					end
				end
			end

			warn("The aura: "..auraName.Name.."  was successfully destroyed!")
			auraName:Destroy()
		end
	end
end


return AuraHandler
2 Likes

omg. thank you, youre a lifesaver. idk how you people do this stuff. yall are genuises i couldve never figured that out haha. tysm!!! have an amazing day or night!!!

1 Like

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