Snippet so far on this random thing. Critique *anything* you want with suggested changes please. Mostly looking for criticism on style so this *should* be enough to go on.
--// MajorCrusader
--------------------> Services <--------------------
local Players = game:GetService("Players");
local Teams = game:GetService("Teams");
--------------------> Constants <--------------------
local MIN_RAIDERS = 3;
local MIN_DEFENDERS = 4;
local RAIDER_COLOR = Teams.Raiders.TeamColor;
local DEFENDER_COLOR = Teams.Defenders.TeamColor;
local TIME_TO_HOLD = 700;
local RAID_LIMIT_TIME = 3600;
--------------------> Objects <--------------------
local RaidSystem = {};
--------------------> Functions <--------------------
-- Recursively loop and disable all pointlights
-- @param Userdata Parent the parent to iterate through
function RaidSystem:DisableAllPointLights(Parent)
for _, Child in pairs(Parent) do
if Child:IsA("PointLight") then
Child.Disabled = true
end
self:DisableAllPointLights(Child);
end
end
-- Count players on a team
-- @param BrickColor3 Color the color of the team to check for
function RaidSystem:TeamCount(Color)
local Count = 0;
for _, Player in pairs(Players:GetPlayers()) do
if Player.TeamColor == Color then
Count = Count + 1;
end
end
return Count;
end
function RaidSystem:ValidRaidCheck()
local RaiderCount = self:TeamCount(RAIDER_COLOR);
local DefenderCount = self:TeamCount(DEFENDER_COLOR);
if RaiderCount >= MIN_RAIDERS and DefenderCount >= MIN_DEFENDERS then
end
end
function RaidSystem:StartRaid()
for _, Player in pairs(Players:GetPlayers()) do
Player:LoadCharacter();
wait(); -- Prevent a little lag
end
end
-- The main loop
function RaidSystem:Main()
while true do
if self:ValidRaidCheck() then
self:StartRaid();
end
wait(1);
end
end
--------------------> Main <--------------------
RaidSystem:Main();
|