I am trying to make a part spawn on a random spawner by using OOP and Modules. Problem is though when I try to get the random spawners it keeps returning as nil. Even though I picked a random spawner. Here is the module
local SpawnModule = {}
--//This module handles random spanwer and gets spawners\\--
function SpawnModule.SetTable(table1)
for index,value in pairs(game.Workspace.Spawns:GetChildren()) do
table.insert(table1,value)
end
end
function SpawnModule.ChoseRandomSpawn(table1)
local Spawn = math.random(1,#table1)
--local picked_value = table1[Spawn]
--print(picked_value.Name)
end
return SpawnModule
MainScript
--local Object = require(script.Parent.Parent.Modules.ObjectModule)
local SpawnModule = require(script.Parent.Parent.Modules.SpawnModule)
local objects = {}
local part = game.ServerStorage:FindFirstChild("Part")
SpawnModule.SetTable(objects)
local spawner = SpawnModule.ChoseRandomSpawn(objects)
local picked_value = objects[spawner]
print(picked_value.Name)
--newobject = Object.new(randomSpawn.Position,part)