My code isn't working, it says that "getRandomIndex is not a valic member of ModuleScript "ServerScriptService.Main.SelectChance"". Can anyone help me with this?
Main:
local replicatedStorage = game:GetService("ReplicatedStorage")
local remotes = replicatedStorage:WaitForChild("Remotes")
local selectChance = script:WaitForChild("SelectChance")
local chanceList = script:WaitForChild("ChanceList")
remotes:WaitForChild("RollFunction").OnServerInvoke = function(player)
local Table = {}
for i = 1, 7 do
table.insert(Table, selectChance.getRandomIndex(chanceList))
end
return Table
end
SelectChance:
return {
getRandomIndex = function(chances)
for i, v in ipairs(chances) do
local randomNum = math.random(1, v[2])
if randomNum == 1 and v[2] > chances[1][2] then
return {
v[1];
v[2];
v[3];
}
end
end
return chances[1]
end,
}