-- functions


local function CreateSquad(name)
	if not name then
		name	= HttpService:GenerateGUID(false)
	end
	
	local squad		= script.Squad:Clone()
		squad.Name		= name
		squad.Parent	= SQUADS
		
	return squad
end

local function GetSquad(player)
	for _, squad in pairs(SQUADS:GetChildren()) do
		if squad:FindFirstChild(player.Name) then
			return squad
		end
	end
end

local function AddPlayerToSquad(player, squad)
	local playerValue	= Instance.new("ObjectValue")
		playerValue.Name	= player.Name
		playerValue.Value	= player
		playerValue.Parent	= squad
end

local function RemovePlayer(player)
	for _, squad in pairs(SQUADS:GetChildren()) do
		local playerValue	= squad:FindFirstChild(player.Name)
		
		if playerValue then
			playerValue:Destroy()
		end
	end
end
