Requested module experienced an error while loading

Hey! I’ve been making my game and I’ve ran into this issue 10s of times. I haven’t been able to figure out why this happens, so I end up having to rewrite the entire module. Does anyone know what the error Requested module experienced an error while loading actually means and how to fix it?

  • I’ve already searched the error up and looked everywhere for answers, none of which actually told me how to fix the problem

MODULE:

local DataManager = require(game.ReplicatedStorage.Modules.DataManager)
local PlantsFolder = script.Plants

local function PlantToModel(plant,Stage)
	print("other1")
	return PlantsFolder:FindFirstDescendant(plant.. Stage)
end

local PlantManager = {}

function PlantManager.Plant(plr,Plot,Tile,Plant)
	local Data = DataManager:Get(plr)
	if Tile.Main.Plant.Value == "None" then
		Data.Plot.CanvasObjects[Tile.PrimaryPart.Serial.Value].Crop = Plant
		local Clone = PlantToModel(Plant.. 1):Clone()
		Clone.Parent = Tile
		Clone:SetPrimaryPartCFrame(Tile.PrimaryPart.CFrame)
	end
end


return PlantManager

Whenever I remove:

local DataManager = require(game.ReplicatedStorage.Modules.DataManager)

The entire game will run perfectly with no errors, is this a problem with the Data system? I’m currently using ProfileService to keep all my data. So if anyone has any ideas for what’s wrong, that would be amazing.

@loleris Could this be a possible ProfileService bug? I’m not sure. Heres the data manager incase this does actually have to do with ProfileService.


local Players = game:GetService("Players")

local ProfileService = require(game.ReplicatedStorage.Modules.ProfileService)

local ProfileStore = ProfileService.GetProfileStore(
	"Player",
	{
		Cash = 0;
		
		LoginTimes = 0;
		RobuxSpent = 0;
		
		Inventory = {};
		
		Tools = {};
		
		Avatar = {
			Accessories = {},SkinColor = {R = 0,G = 0,B = 0},HairColor = {R = 0,G = 0,B = 0},Package = 0,Face = 0,Top = 0,Bottom = 0
		};
		
		Plot = {
			
			Objs = 0,
			Strs = 0,
			
			CanvasObjects = {},
			Structures = {}
			
		};
		
		Settings = {};
		Whitelist = {};
	}
)

local Profiles = {}

local function onPlayerAdded(player)
	local profile = ProfileStore:LoadProfileAsync(
		"Player_".. player.UserId,
		"ForceLoad"
	)
	
	if profile then
		profile:Reconcile()
		profile:ListenToRelease(function()
			Profiles[player] = nil
			player:Kick()
		end)
		
		if player:IsDescendantOf(Players) then
			Profiles[player] = profile
			Profiles[player].Data.LoginTimes += 1
			print(player.Name.. " has joined ".. Profiles[player].Data.LoginTimes.. " times.")
			print(Profiles[player].Data)
		else
			profile:Release()
		end
	else
		player:Kick()
	end
end

local function onPlayerRemoving(player)
	local profile = Profiles[player]
	if profile then
		profile:Release()
	end
end

Players.PlayerAdded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(onPlayerRemoving)

local DataManager = {}

function DataManager:Get(player)
	local profile = Profiles[player]
	
	if profile then
		return profile.Data
	end
end
return DataManager

1 Like

Do you Mind Showing the Explorer? (A Picture)
Also Try Changing That to

local DataManager = require(game.ReplicatedStorage:WaitForChild("Modules"):WaitForChild("DataManager"))
1 Like

Also after changing it to that it didn’t change anything.

1 Like

Are you having the client call on datamanger?

I put my profile service module within ServerScriptService

2 Likes

The Server is calling the PlantManager.Plant function, so no its not. I’ll try putting ProfileService into server script service and change it up a little real quick.

After doing that, all the errors stopped popping up. But now I get a infinite yield on profile service NOT being in server script service
Screen Shot 2021-07-10 at 9.00.48 AM

Why do you need your data managing modules in replicated storage though?(or the clientside in general)

it would of been better just to put profileService and datamanger within SSS

your error is that datamanager is being called by the client not profileserivce

also the client cannot access SSS so that makes sense why it was yielding

1 Like

OH! I fixed it, I’m sorry if I wasted your time at all. THANK you soooo much, basically the Client was calling the module and the first line was to call the data manger, but obviously it can’t do that because its the client. Thanks dude lol

1 Like