hello yet again my favorite scripters
i have a system that spans over two scripts. one is a module, another is a server script.
i have a module script, here’s how it works.
local module = {}
local player = game:GetService("Players")
local teams = game:GetService("Teams")
function module.AssignCatcher()
local players = player:GetPlayers()
if #players > 1 then
local randomplayer = players[math.random(1, #players)]
local catcher = players[randomplayer]
catcher.Team = teams.Catcher
else
warn("0 players on the server. wtf?")
end
end
return module
issue is that, when the players table player:GetPlayers() table is invoked, it always returns nothing.
i tried doing print(game.Players:GetPlayers()) while in testing mode and it returned the current player table, not an empty table.
![]()
i really have no idea on this one. i tried looking for solutions at other topics, but no dice.
here’s the script that involves the module.
local serverstorage = game:GetService("ServerStorage")
local repstorage = game:GetService("ReplicatedStorage")
local serverscript = game:GetService("ServerScriptService")
local assigncatcher = require(serverscript.AssignCatcher)
local lobby = serverstorage.Lobby:Clone() -- spawn a lobby on init
local map = serverstorage.Map:Clone()
lobby:Clone()
lobby.Parent = game:GetService("Workspace")
repstorage.TimerOver.Event:Connect(function(roundtype)
if roundtype == "Lobby" then
lobby:Destroy()
map:Clone()
map.Parent = game:GetService("Workspace")
assigncatcher.AssignCatcher()
end
end)