Requested module experienced an error while loading

i am trying to make script that gets number from table
i getting error about it Requested module experienced an error while loading.
Π‘Π½ΠΈΠΌΠΎΠΊ экрана 2024-03-09 003710
, module:


server script:
Π‘Π½ΠΈΠΌΠΎΠΊ экрана 2024-03-09 003959

i tried to restart studio and changed script many times
module code

wait(10)
local barrelsdata = {
 ["Barrels"] = {
		["Cherry"] = game.Players.LocalPlayer:FindFirstChild("Inventory").CherryStoredBarrel.Value;	
		["Berry"] = game.Players.LocalPlayer:FindFirstChild("Inventory").BerryStoredBarrel.Value;
		["Normal"] = game.Players.LocalPlayer:FindFirstChild("Inventory").NormalStoredBarrel.Value;
		BarrelAmount = game.Players.LocalPlayer:FindFirstChild("Inventory").CherryStoredBarrel.Value+game.Players.LocalPlayer.Inventory.NormalStoredBarrel.Value+ game.Players.LocalPlayer.Inventory.BerryStoredBarrel.Value;
 };	
	
}
return barrelsdata

i will be grateful if you help me.

game.Players.LocalPlayer

is nil on the server.

1 Like

In the module, you are referencing LocalPlayer. As you are requiring this from a server script, it is not going to have a valid variable, as LocalPlayer only exists on the client.

@RickAstll3y how do i can fix it. When i use plr added function it gives different errors.

why would your module need to yield?
Give us more context about barreldata in server script, por favor.

just forget about β€œwait”, it was experiment.

I have many barrel givers and it have maximum barrel limit. So i have different barrels. Module make formula of summa of all barrels. And sent this formula to script and he checks, do player dont reached his inventory limit. But my script is server sided and idk how to get player in module script.

I recommend getting the player from the server script that requires this module and changing the module to only reference the barrelsdata:

local barrelsdata = {
 ["Barrels"] = {
		["Cherry"] = CherryStoredBarrel.Value;	
		["Berry"] = BerryStoredBarrel.Value;
		["Normal"] = NormalStoredBarrel.Value;
		BarrelAmount = CherryStoredBarrel.Value + NormalStoredBarrel.Value + BerryStoredBarrel.Value;
 };
}

Then in your server script, set the player value and Inventory, for example:

local barreldata= require(game.ReplicatedStorage:WaitForChild("BarrelsData"))
local function getbarreldata(player)
	local inventory = player:FindFirstChild("Inventory")
	local barrels = barreldata["Barrels"]
	local cherry = inventory:FindFirstChild(barrels ["Cherry"])
end

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