Issues with Gacha System (aka pet system from Alvin Blox

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I am trying to achieve a system where the module script chooses an item in the table of items based on their rarities
  2. What is the issue? Include screenshots / videos if possible!
    I was confused with this during the tutorial but the return script doesn’t seem to understand NormModule.RandomItem()
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have rewatched the video because im guessing that could be the issue
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
-- Module script (norm just means normal)

local NormModule = {}

local NormList = game.ServerScriptService.PlayerEnteringValues.OwnerValues
-- Put each pet to rarity
NormModule.items = {


	["Elite"] = {
		NormList["7"], 
	};

	["Legendary"] = {
		NormList["6"], 
	};

	["Epic"] = {
		NormList["5"], 
	};

	["Rare"] = {
		NormList["4"], 
	};
	
	["Common"] = {
		NormList["1"], NormList["2"], NormList["3"], 
	};	
	
}
-- set rarity weights
NormModule.rarities = {

	["Elite"] = 0; -- ignore this zero i just want it to be unobtainable for now

	["Legendary"] = 2;
	
	["Epic"] = 20;

	["Rare"] = 37;

	["Common"] = 41;

}

--Function of choosing pet
NormModule.RandomItem = function()
	local Ranum = math.random(1, 100)
	local counter = 0 
	for rarity, weight in pairs(NormModule.rarities) do 
		counter = counter + weight
		if Ranum <= counter then
			local raritytable = NormModule.items[rarity]
			local choosenitem = raritytable[math.random(1, #raritytable)]

			return choosenitem
		end
	end
end




return NormModule

--return script (server script)

REM.OnServerEvent:Connect(function(player)
	print("received")
	local Money = player[player.Name .."CurrencyValues"].Money
	if Money.Value >= 100 then
		Money.Value = Money.Value - 100
		local item = Mod.RandomItem()   -- Basically the only important part
		print(player.Name .. "Has Pulled" .. item.Name)  
	else
		print("not enough money")
			
	end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.